home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / benchmarks / itc / cc1.spur / expr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-04  |  128.1 KB  |  4,361 lines

  1. /* Convert tree expression to rtl instructions, for GNU compiler.
  2.    Copyright (C) 1988 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY.  No author or distributor
  8. accepts responsibility to anyone for the consequences of using it
  9. or for whether it serves any particular purpose or works at all,
  10. unless he says so in writing.  Refer to the GNU CC General Public
  11. License for full details.
  12.  
  13. Everyone is granted permission to copy, modify and redistribute
  14. GNU CC, but only under the conditions described in the
  15. GNU CC General Public License.   A copy of this license is
  16. supposed to have been given to you along with GNU CC so you
  17. can know your rights and responsibilities.  It should be in a
  18. file named COPYING.  Among other things, the copyright notice
  19. and this notice must be preserved on all copies.  */
  20.  
  21.  
  22. #include "config.h"
  23. #include "rtl.h"
  24. #include "tree.h"
  25. #include "flags.h"
  26. #include "insn-flags.h"
  27. #include "insn-codes.h"
  28. #include "expr.h"
  29. #include "insn-config.h"
  30. #include "recog.h"
  31. #include "varargs.h"
  32. #include "alloca.h"
  33.  
  34. /* Decide whether a function's arguments should be processed
  35.    from first to last or from last to first.  */
  36.  
  37. #ifdef STACK_GROWS_DOWNWARD
  38. #ifdef PUSH_ROUNDING
  39. #define PUSH_ARGS_REVERSED    /* If it's last to first */
  40. #endif
  41. #endif
  42.  
  43. /* Like STACK_BOUNDARY but in units of bytes, not bits.  */
  44. #define STACK_BYTES (STACK_BOUNDARY / BITS_PER_UNIT)
  45.  
  46. /* If this is nonzero, we do not bother generating VOLATILE
  47.    around volatile memory references, and we are willing to
  48.    output indirect addresses.  If cse is to follow, we reject
  49.    indirect addresses so a useful potential cse is generated;
  50.    if it is used only once, instruction combination will produce
  51.    the same indirect address eventually.  */
  52. int cse_not_expected;
  53.  
  54. /* Nonzero to generate code for all the subroutines within an
  55.    expression before generating the upper levels of the expression.
  56.    Nowadays this is never zero.  */
  57. int do_preexpand_calls = 1;
  58.  
  59. /* Number of units that we should eventually pop off the stack.
  60.    These are the arguments to function calls that have already returned.  */
  61. int pending_stack_adjust;
  62.  
  63. /* Total size of arguments already pushed for function calls that
  64.    have not happened yet.  When this is nonzero,
  65.    args passed to function calls must be popped right away
  66.    to ensure contiguity of argument lists for future calls.
  67.  
  68.    This can also be temporarily incremented for various other reasons
  69.    to inhibit deferring of pops.  */
  70. static int current_args_size;
  71.  
  72. #define NO_DEFER_POP current_args_size += 1
  73. #define OK_DEFER_POP current_args_size -= 1
  74.  
  75. /* Nonzero means current function may call alloca.  */
  76. int may_call_alloca;
  77.  
  78. rtx store_expr ();
  79. static void store_constructor ();
  80. static rtx store_field ();
  81. static rtx expand_call ();
  82. static void emit_call_1 ();
  83. static rtx prepare_call_address ();
  84. static rtx expand_builtin ();
  85. static rtx compare ();
  86. static rtx compare_constants ();
  87. static rtx compare1 ();
  88. static rtx do_store_flag ();
  89. static void preexpand_calls ();
  90. static rtx expand_increment ();
  91. static void move_by_pieces_1 ();
  92. static int move_by_pieces_ninsns ();
  93. static void init_queue ();
  94.  
  95. void do_pending_stack_adjust ();
  96.  
  97. /* MOVE_RATIO is the number of move instructions that is better than
  98.    a block move.  */
  99.  
  100. #if defined (HAVE_movstrhi) || defined (HAVE_movstrsi)
  101. #define MOVE_RATIO 2
  102. #else
  103. #define MOVE_RATIO 6
  104. #endif
  105.  
  106. /* Table indexed by tree code giving 1 if the code is for a
  107.    comparison operation, or anything that is most easily
  108.    computed with a conditional branch.
  109.  
  110.    We include tree.def to give it the proper length.
  111.    The contents thus created are irrelevant.
  112.    The real contents are initialized in init_comparisons.  */
  113.  
  114. #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) 0,
  115.  
  116. static char comparison_code[] = {
  117. #include "tree.def"
  118. };
  119. #undef DEFTREECODE
  120.  
  121. /* This is run once per compilation.  */
  122.  
  123. void
  124. init_comparisons ()
  125. {
  126.   comparison_code[(int) EQ_EXPR] = 1;
  127.   comparison_code[(int) NE_EXPR] = 1;
  128.   comparison_code[(int) LT_EXPR] = 1;
  129.   comparison_code[(int) GT_EXPR] = 1;
  130.   comparison_code[(int) LE_EXPR] = 1;
  131.   comparison_code[(int) GE_EXPR] = 1;
  132. }
  133.  
  134. /* This is run at the start of compiling a function.  */
  135.  
  136. void
  137. init_expr ()
  138. {
  139.   init_queue ();
  140.   may_call_alloca = 0;
  141. }
  142.  
  143. /* Manage the queue of increment instructions to be output
  144.    for POSTINCREMENT_EXPR expressions, etc.  */
  145.  
  146. static rtx pending_chain;
  147.  
  148. /* Queue up to increment (or change) VAR later.  BODY says how:
  149.    BODY should be the same thing you would pass to emit_insn
  150.    to increment right away.  It will go to emit_insn later on.
  151.  
  152.    The value is a QUEUED expression to be used in place of VAR
  153.    where you want to guarantee the pre-incrementation value of VAR.  */
  154.  
  155. static rtx
  156. enqueue_insn (var, body)
  157.      rtx var, body;
  158. {
  159.   pending_chain = gen_rtx (QUEUED, GET_MODE (var),
  160.                var, 0, 0, body, pending_chain);
  161.   return pending_chain;
  162. }
  163.  
  164. /* Use protect_from_queue to convert a QUEUED expression
  165.    into something that you can put immediately into an instruction.
  166.    If the queued incrementation has not happened yet,
  167.    protect_from_queue returns the variable itself.
  168.    If the incrementation has happened, protect_from_queue returns a temp
  169.    that contains a copy of the old value of the variable.
  170.  
  171.    Any time an rtx which might possibly be a QUEUED is to be put
  172.    into an instruction, it must be passed through protect_from_queue first.
  173.    QUEUED expressions are not meaningful in instructions.
  174.  
  175.    Do not pass a value through protect_from_queue and then hold
  176.    on to it for a while before putting it in an instruction!
  177.    If the queue is flushed in between, incorrect code will result.  */
  178.  
  179. rtx
  180. protect_from_queue (x, modify)
  181.      register rtx x;
  182.      int modify;
  183. {
  184.   register RTX_CODE code = GET_CODE (x);
  185.   if (code != QUEUED)
  186.     {
  187.       /* A special hack for read access to (MEM (QUEUED ...))
  188.      to facilitate use of autoincrement.
  189.      Make a copy of the contents of the memory location
  190.      rather than a copy of the address.  */
  191.       if (code == MEM && GET_CODE (XEXP (x, 0)) == QUEUED && !modify)
  192.     {
  193.       register rtx y = XEXP (x, 0);
  194.       XEXP (x, 0) = QUEUED_VAR (y);
  195.       if (QUEUED_INSN (y))
  196.         {
  197.           register rtx temp = gen_reg_rtx (GET_MODE (x));
  198.           emit_insn_before (gen_move_insn (temp, x),
  199.                 QUEUED_INSN (y));
  200.           return temp;
  201.         }
  202.       return x;
  203.     }
  204.       /* Otherwise, recursively protect the subexpressions of all
  205.      the kinds of rtx's that can contain a QUEUED.  */
  206.       if (code == MEM)
  207.     XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
  208.       else if (code == PLUS || code == MULT)
  209.     {
  210.       XEXP (x, 0) = protect_from_queue (XEXP (x, 0), 0);
  211.       XEXP (x, 1) = protect_from_queue (XEXP (x, 1), 0);
  212.     }
  213.       return x;
  214.     }
  215.   /* If the increment has not happened, use the variable itself.  */
  216.   if (QUEUED_INSN (x) == 0)
  217.     return QUEUED_VAR (x);
  218.   /* If the increment has happened and a pre-increment copy exists,
  219.      use that copy.  */
  220.   if (QUEUED_COPY (x) != 0)
  221.     return QUEUED_COPY (x);
  222.   /* The increment has happened but we haven't set up a pre-increment copy.
  223.      Set one up now, and use it.  */
  224.   QUEUED_COPY (x) = gen_reg_rtx (GET_MODE (QUEUED_VAR (x)));
  225.   emit_insn_before (gen_move_insn (QUEUED_COPY (x), QUEUED_VAR (x)),
  226.             QUEUED_INSN (x));
  227.   return QUEUED_COPY (x);
  228. }
  229.  
  230. /* Return nonzero if X contains a QUEUED expression:
  231.    if it contains anything that will be altered by a queued increment.  */
  232.  
  233. static int
  234. queued_subexp_p (x)
  235.      rtx x;
  236. {
  237.   register enum rtx_code code = GET_CODE (x);
  238.   switch (code)
  239.     {
  240.     case QUEUED:
  241.       return 1;
  242.     case MEM:
  243.       return queued_subexp_p (XEXP (x, 0));
  244.     case MULT:
  245.     case PLUS:
  246.     case MINUS:
  247.       return queued_subexp_p (XEXP (x, 0))
  248.     || queued_subexp_p (XEXP (x, 1));
  249.     }
  250.   return 0;
  251. }
  252.  
  253. /* Perform all the pending incrementations.  */
  254.  
  255. void
  256. emit_queue ()
  257. {
  258.   register rtx p;
  259.   while (p = pending_chain)
  260.     {
  261.       QUEUED_INSN (p) = emit_insn (QUEUED_BODY (p));
  262.       pending_chain = QUEUED_NEXT (p);
  263.     }
  264. }
  265.  
  266. static void
  267. init_queue ()
  268. {
  269.   if (pending_chain)
  270.     abort ();
  271. }
  272.  
  273. /* Copy data from FROM to TO, where the machine modes are not the same.
  274.    Both modes may be integer, or both may be floating.
  275.    UNSIGNEDP should be nonzero if FROM is an unsigned type.
  276.    This causes zero-extension instead of sign-extension.  */
  277.  
  278. void
  279. convert_move (to, from, unsignedp)
  280.      register rtx to, from;
  281.      int unsignedp;
  282. {
  283.   enum machine_mode to_mode = GET_MODE (to);
  284.   enum machine_mode from_mode = GET_MODE (from);
  285.   int to_real = to_mode == SFmode || to_mode == DFmode;
  286.   int from_real = from_mode == SFmode || from_mode == DFmode;
  287.   int extending = (int) to_mode > (int) from_mode;
  288.  
  289.   to = protect_from_queue (to, 1);
  290.   from = protect_from_queue (from, 0);
  291.  
  292.   if (to_real != from_real)
  293.     abort ();
  294.  
  295.   if (to_mode == from_mode
  296.       || (from_mode == VOIDmode && CONSTANT_P (from)))
  297.     {
  298.       emit_move_insn (to, from);
  299.       return;
  300.     }
  301.  
  302.   if (to_real)
  303.     {
  304. #ifdef HAVE_extendsfdf2
  305.       if (HAVE_extendsfdf2 && extending)
  306.     {
  307.       emit_unop_insn (CODE_FOR_extendsfdf2, to, from, UNKNOWN);
  308.       return;
  309.     }
  310. #endif
  311. #ifdef HAVE_truncdfsf2
  312.       if (HAVE_truncdfsf2 && ! extending)
  313.     {
  314.       emit_unop_insn (CODE_FOR_truncdfsf2, to, from, UNKNOWN);
  315.       return;
  316.     }
  317. #endif
  318.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, (extending
  319.                               ? "_extendsfdf2"
  320.                               : "_truncdfsf2")),
  321.              GET_MODE (to), 1,
  322.              from,  (extending ? SFmode : DFmode));
  323.       emit_move_insn (to, hard_libcall_value (GET_MODE (to)));
  324.       return;
  325.     }
  326.  
  327.   /* Now both modes are integers.  */
  328.  
  329.   if (to_mode == DImode)
  330.     {
  331.       if (unsignedp)
  332.     {
  333.       emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  334.       convert_move (gen_lowpart (SImode, to), from, unsignedp);
  335.       emit_clr_insn (gen_highpart (SImode, to));
  336.     }
  337. #ifdef HAVE_extendsidi2
  338.       else if (HAVE_extendsidi2)
  339.         emit_insn (gen_extendsidi2 (to, from));
  340. #endif
  341. #ifdef HAVE_slt
  342.       else if (HAVE_slt && insn_operand_mode[(int) CODE_FOR_slt][0] == SImode)
  343.     {
  344.       emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  345.       convert_move (gen_lowpart (SImode, to), from, unsignedp);
  346.       emit_insn (gen_slt (gen_highpart (SImode, to)));
  347.     }
  348. #endif
  349.       else
  350.     {
  351.       register rtx label = gen_label_rtx ();
  352.  
  353.       emit_insn (gen_rtx (CLOBBER, VOIDmode, to));
  354.       emit_clr_insn (gen_highpart (SImode, to));
  355.       convert_move (gen_lowpart (SImode, to), from, unsignedp);
  356.       emit_cmp_insn (gen_lowpart (SImode, to),
  357.              gen_rtx (CONST_INT, VOIDmode, 0),
  358.              0, 0);
  359.       NO_DEFER_POP;
  360.       emit_jump_insn (gen_bge (label));
  361.       expand_unop (SImode, one_cmpl_optab,
  362.                gen_highpart (SImode, to), gen_highpart (SImode, to),
  363.                1);
  364.       emit_label (label);
  365.       OK_DEFER_POP;
  366.     }
  367.       return;
  368.     }
  369.  
  370.   if (from_mode == DImode)
  371.     {
  372.       convert_move (to, gen_lowpart (SImode, from), 0);
  373.       return;
  374.     }
  375.  
  376.   /* Now follow all the conversions between integers
  377.      no more than a word long.  */
  378.  
  379.   /* For truncation, usually we can just refer to FROM in a narrower mode.  */
  380.   if (GET_MODE_BITSIZE (to_mode) < GET_MODE_BITSIZE (from_mode)
  381.       && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (to_mode),
  382.                 GET_MODE_BITSIZE (from_mode))
  383.       && ((GET_CODE (from) == MEM
  384.        && ! mode_dependent_address_p (XEXP (from, 0)))
  385.       || GET_CODE (from) == REG))
  386.     {
  387.       emit_move_insn (to, gen_lowpart (to_mode, from));
  388.       return;
  389.     }
  390.  
  391.   if (to_mode == SImode && from_mode == HImode)
  392.     {
  393.       if (unsignedp)
  394.     {
  395. #ifdef HAVE_zero_extendhisi2
  396.       if (HAVE_zero_extendhisi2)
  397.         emit_unop_insn (CODE_FOR_zero_extendhisi2, to, from, ZERO_EXTEND);
  398.       else
  399. #endif
  400.         abort ();
  401.     }
  402.       else
  403.     {
  404. #ifdef HAVE_extendhisi2
  405.       if (HAVE_extendhisi2)
  406.         emit_unop_insn (CODE_FOR_extendhisi2, to, from, SIGN_EXTEND);
  407.       else
  408. #endif
  409.         abort ();
  410.     }
  411.       return;
  412.     }
  413.  
  414.   if (to_mode == SImode && from_mode == QImode)
  415.     {
  416.       if (unsignedp)
  417.     {
  418. #ifdef HAVE_zero_extendqisi2
  419.       if (HAVE_zero_extendqisi2)
  420.         {
  421.           emit_unop_insn (CODE_FOR_zero_extendqisi2, to, from, ZERO_EXTEND);
  422.           return;
  423.         }
  424. #endif
  425. #if defined (HAVE_zero_extendqihi2) && defined (HAVE_extendhisi2)
  426.       if (HAVE_zero_extendqihi2 && HAVE_extendhisi2)
  427.         {
  428.           register rtx temp = gen_reg_rtx (HImode);
  429.           emit_unop_insn (CODE_FOR_zero_extendqihi2, temp, from, ZERO_EXTEND);
  430.           emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
  431.           return;
  432.         }
  433. #endif
  434.     }
  435.       else
  436.     {
  437. #ifdef HAVE_extendqisi2
  438.       if (HAVE_extendqisi2)
  439.         {
  440.           emit_unop_insn (CODE_FOR_extendqisi2, to, from, SIGN_EXTEND);
  441.           return;
  442.         }
  443. #endif
  444. #if defined (HAVE_extendqihi2) && defined (HAVE_extendhisi2)
  445.       if (HAVE_extendqihi2 && HAVE_extendhisi2)
  446.         {
  447.           register rtx temp = gen_reg_rtx (HImode);
  448.           emit_unop_insn (CODE_FOR_extendqihi2, temp, from, SIGN_EXTEND);
  449.           emit_unop_insn (CODE_FOR_extendhisi2, to, temp, SIGN_EXTEND);
  450.           return;
  451.         }
  452. #endif
  453.     }
  454.       abort ();
  455.     }
  456.  
  457.   if (to_mode == HImode && from_mode == QImode)
  458.     {
  459.       if (unsignedp)
  460.     {
  461. #ifdef HAVE_zero_extendqihi2
  462.       if (HAVE_zero_extendqihi2)
  463.         {
  464.           emit_unop_insn (CODE_FOR_zero_extendqihi2, to, from, ZERO_EXTEND);
  465.           return;
  466.         }
  467. #endif
  468.     }
  469.       else
  470.     {
  471. #ifdef HAVE_extendqihi2
  472.       if (HAVE_extendqihi2)
  473.         {
  474.           emit_unop_insn (CODE_FOR_extendqihi2, to, from, SIGN_EXTEND);
  475.           return;
  476.         }
  477. #endif
  478.     }
  479.       abort ();
  480.     }
  481.  
  482.   /* Now we are truncating an integer to a smaller one.
  483.      If the result is a temporary, we might as well just copy it,
  484.      since only the low-order part of the result needs to be valid
  485.      and it is valid with no change.  */
  486.  
  487.   if (GET_CODE (to) == REG)
  488.     {
  489.       if (GET_CODE (from) == REG)
  490.     {
  491.       emit_move_insn (to, gen_lowpart (GET_MODE (to), from));
  492.       return;
  493.     }
  494.       else if (GET_CODE (from) == SUBREG)
  495.     {
  496.       from = copy_rtx (from);
  497.       /* This is safe since FROM is not more than one word.  */
  498.       PUT_MODE (from, GET_MODE (to));
  499.       emit_move_insn (to, from);
  500.       return;
  501.     }
  502. #ifndef BYTES_BIG_ENDIAN
  503.       else if (GET_CODE (from) == MEM)
  504.     {
  505.       register rtx addr = XEXP (from, 0);
  506.       if (memory_address_p (GET_MODE (to), addr))
  507.         {
  508.           emit_move_insn (to, gen_rtx (MEM, GET_MODE (to), addr));
  509.           return;
  510.         }
  511.     }
  512. #endif /* not BYTES_BIG_ENDIAN */
  513.     }
  514.  
  515.   if (from_mode == SImode && to_mode == HImode)
  516.     {
  517. #ifdef HAVE_truncsihi2
  518.       if (HAVE_truncsihi2)
  519.     {
  520.       emit_unop_insn (CODE_FOR_truncsihi2, to, from, UNKNOWN);
  521.       return;
  522.     }
  523. #endif
  524.       abort ();
  525.     }
  526.  
  527.   if (from_mode == SImode && to_mode == QImode)
  528.     {
  529. #ifdef HAVE_truncsiqi2
  530.       if (HAVE_truncsiqi2)
  531.     {
  532.       emit_unop_insn (CODE_FOR_truncsiqi2, to, from, UNKNOWN);
  533.       return;
  534.     }
  535. #endif
  536.       abort ();
  537.     }
  538.  
  539.   if (from_mode == HImode && to_mode == QImode)
  540.     {
  541. #ifdef HAVE_trunchiqi2
  542.       if (HAVE_trunchiqi2)
  543.     {
  544.       emit_unop_insn (CODE_FOR_trunchiqi2, to, from, UNKNOWN);
  545.       return;
  546.     }
  547. #endif
  548.       abort ();
  549.     }
  550.  
  551.   /* Mode combination is not recognized.  */
  552.   abort ();
  553. }
  554.  
  555. /* Return an rtx for a value that would result
  556.    from converting X to mode MODE.
  557.    Both X and MODE may be floating, or both integer.
  558.    UNSIGNEDP is nonzero if X is an unsigned value.
  559.    This can be done by referring to a part of X in place
  560.    or by copying to a new temporary with conversion.  */
  561.  
  562. rtx
  563. convert_to_mode (mode, x, unsignedp)
  564.      enum machine_mode mode;
  565.      rtx x;
  566.      int unsignedp;
  567. {
  568.   register rtx temp;
  569.   if (mode == GET_MODE (x))
  570.     return x;
  571.   if (integer_mode_p (mode)
  572.       && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (x)))
  573.     return gen_lowpart (mode, x);
  574.   temp = gen_reg_rtx (mode);
  575.   convert_move (temp, x, unsignedp);
  576.   return temp;
  577. }
  578.  
  579. int
  580. integer_mode_p (mode)
  581.      enum machine_mode mode;
  582. {
  583.   return (int) mode > (int) VOIDmode && (int) mode <= (int) TImode;
  584. }
  585.  
  586. /* Generate several move instructions to copy LEN bytes
  587.    from block FROM to block TO.  (These are MEM rtx's with BLKmode).
  588.    The caller must pass FROM and TO
  589.     through protect_from_queue before calling.
  590.    ALIGN (in bytes) is maximum alignment we can assume.  */
  591.  
  592. struct move_by_pieces
  593. {
  594.   rtx to;
  595.   rtx to_addr;
  596.   int autinc_to;
  597.   int explicit_inc_to;
  598.   rtx from;
  599.   rtx from_addr;
  600.   int autinc_from;
  601.   int explicit_inc_from;
  602.   int len;
  603.   int offset;
  604.   int reverse;
  605. };
  606.  
  607. static void
  608. move_by_pieces (to, from, len, align)
  609.      rtx to, from;
  610.      int len, align;
  611. {
  612.   struct move_by_pieces data;
  613.   rtx to_addr = XEXP (to, 0), from_addr = XEXP (from, 0);
  614.  
  615.   data.offset = 0;
  616.   data.to_addr = to_addr;
  617.   data.from_addr = from_addr;
  618.   data.to = to;
  619.   data.from = from;
  620.   data.autinc_to
  621.     = (GET_CODE (to_addr) == PRE_INC || GET_CODE (to_addr) == PRE_DEC
  622.        || GET_CODE (to_addr) == POST_INC || GET_CODE (to_addr) == POST_DEC);
  623.   data.autinc_from
  624.     = (GET_CODE (from_addr) == PRE_INC || GET_CODE (from_addr) == PRE_DEC
  625.        || GET_CODE (from_addr) == POST_INC
  626.        || GET_CODE (from_addr) == POST_DEC);
  627.  
  628.   data.explicit_inc_from = 0;
  629.   data.explicit_inc_to = 0;
  630.   data.reverse
  631.     = (GET_CODE (to_addr) == PRE_DEC || GET_CODE (to_addr) == POST_DEC);
  632.   if (data.reverse) data.offset = len;
  633.   data.len = len;
  634.  
  635.   /* If copying requires more than two move insns,
  636.      copy addresses to registers (to make displacements shorter)
  637.      and use post-increment if available.  */
  638.   if (!(data.autinc_from && data.autinc_to)
  639.       && move_by_pieces_ninsns (len, align) > 2)
  640.     {
  641. #ifdef HAVE_PRE_DECREMENT
  642.       if (data.reverse && ! data.autinc_from)
  643.     {
  644.       data.from_addr = copy_addr_to_reg (plus_constant (from_addr, len));
  645.       data.autinc_from = 1;
  646.       data.explicit_inc_from = -1;
  647.     }
  648. #endif
  649. #ifdef HAVE_POST_INCREMENT
  650.       if (! data.autinc_from)
  651.     {
  652.       data.from_addr = copy_addr_to_reg (from_addr);
  653.       data.autinc_from = 1;
  654.       data.explicit_inc_from = 1;
  655.     }
  656. #endif
  657.       if (!data.autinc_from && CONSTANT_P (from_addr))
  658.     data.from_addr = copy_addr_to_reg (from_addr);
  659. #ifdef HAVE_PRE_DECREMENT
  660.       if (data.reverse && ! data.autinc_to)
  661.     {
  662.       data.to_addr = copy_addr_to_reg (plus_constant (to_addr, len));
  663.       data.autinc_to = 1;
  664.       data.explicit_inc_to = -1;
  665.     }
  666. #endif
  667. #ifdef HAVE_POST_INCREMENT
  668.       if (! data.reverse && ! data.autinc_to)
  669.     {
  670.       data.to_addr = copy_addr_to_reg (to_addr);
  671.       data.autinc_to = 1;
  672.       data.explicit_inc_to = 1;
  673.     }
  674. #endif
  675.       if (!data.autinc_to && CONSTANT_P (to_addr))
  676.     data.to_addr = copy_addr_to_reg (to_addr);
  677.     }
  678.  
  679. #ifdef STRICT_ALIGNMENT
  680.   if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  681.     align = MOVE_MAX;
  682. #else
  683.   align = MOVE_MAX;
  684. #endif
  685.  
  686. #ifdef HAVE_movti
  687.   if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
  688.     move_by_pieces_1 (gen_movti, TImode, &data);
  689. #endif
  690. #ifdef HAVE_movdi
  691.   if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
  692.     move_by_pieces_1 (gen_movdi, DImode, &data);
  693. #endif
  694. #ifdef HAVE_movsi
  695.   if (align >= GET_MODE_SIZE (SImode))
  696.     move_by_pieces_1 (gen_movsi, SImode, &data);
  697. #endif
  698. #ifdef HAVE_movhi
  699.   if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
  700.     move_by_pieces_1 (gen_movhi, HImode, &data);
  701. #endif
  702. #ifdef HAVE_movqi
  703.   move_by_pieces_1 (gen_movqi, QImode, &data);
  704. #else
  705.   movqi instruction required in machine description
  706. #endif
  707. }
  708.  
  709. /* Return number of insns required to move L bytes by pieces.
  710.    ALIGN (in bytes) is maximum alignment we can assume.  */
  711.  
  712. static int
  713. move_by_pieces_ninsns (l, align)
  714.      unsigned int l;
  715.      int align;
  716. {
  717.   register int n_insns = 0;
  718.  
  719. #ifdef STRICT_ALIGNMENT
  720.   if (align > MOVE_MAX || align >= BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  721.     align = MOVE_MAX;
  722. #else
  723.   align = MOVE_MAX;
  724. #endif
  725.  
  726. #ifdef HAVE_movti
  727.   if (HAVE_movti && align >= GET_MODE_SIZE (TImode))
  728.     n_insns += l / GET_MODE_SIZE (TImode), l %= GET_MODE_SIZE (TImode);
  729. #endif
  730. #ifdef HAVE_movdi
  731.   if (HAVE_movdi && align >= GET_MODE_SIZE (DImode))
  732.     n_insns += l / GET_MODE_SIZE (DImode), l %= GET_MODE_SIZE (DImode);
  733. #endif
  734. #ifdef HAVE_movsi
  735.   if (HAVE_movsi && align >= GET_MODE_SIZE (SImode))
  736.     n_insns += l / GET_MODE_SIZE (SImode), l %= GET_MODE_SIZE (SImode);
  737. #endif
  738. #ifdef HAVE_movhi
  739.   if (HAVE_movhi && align >= GET_MODE_SIZE (HImode))
  740.     n_insns += l / GET_MODE_SIZE (HImode), l %= GET_MODE_SIZE (HImode);
  741. #endif
  742.   n_insns += l;
  743.  
  744.   return n_insns;
  745. }
  746.  
  747. /* Subroutine of move_by_pieces.  Move as many bytes as appropriate
  748.    with move instructions for mode MODE.  GENFUN is the gen_... function
  749.    to make a move insn for that mode.  DATA has all the other info.  */
  750.  
  751. static void
  752. move_by_pieces_1 (genfun, mode, data)
  753.      rtx (*genfun) ();
  754.      enum machine_mode mode;
  755.      struct move_by_pieces *data;
  756. {
  757.   register int size = GET_MODE_SIZE (mode);
  758.   register rtx to1, from1;
  759.  
  760. #define add_offset(FLAG,X)  \
  761.    (FLAG ? (X) : plus_constant ((X), data->offset))
  762.  
  763.   while (data->len >= size)
  764.     {
  765.       if (data->reverse) data->offset -= size;
  766.  
  767.       to1 = change_address (data->to, mode,
  768.                 add_offset (data->autinc_to, data->to_addr));
  769.       from1 = change_address (data->from, mode,
  770.                   add_offset (data->autinc_from, data->from_addr));
  771.  
  772. #ifdef HAVE_PRE_DECREMENT
  773.       if (data->explicit_inc_to < 0)
  774.     emit_insn (gen_sub2_insn (data->to_addr,
  775.                   gen_rtx (CONST_INT, VOIDmode, size)));
  776.       if (data->explicit_inc_from < 0)
  777.     emit_insn (gen_sub2_insn (data->from_addr,
  778.                   gen_rtx (CONST_INT, VOIDmode, size)));
  779. #endif
  780.  
  781.       emit_insn ((*genfun) (to1, from1));
  782. #ifdef HAVE_POST_INCREMENT
  783.       if (data->explicit_inc_to > 0)
  784.     emit_insn (gen_add2_insn (data->to_addr,
  785.                   gen_rtx (CONST_INT, VOIDmode, size)));
  786.       if (data->explicit_inc_from > 0)
  787.     emit_insn (gen_add2_insn (data->from_addr,
  788.                   gen_rtx (CONST_INT, VOIDmode, size)));
  789. #endif
  790.  
  791.       if (! data->reverse) data->offset += size;
  792.  
  793.       data->len -= size;
  794.     }
  795. }
  796.  
  797. /* Emit code to move a block Y to a block X.
  798.    This may be done with string-move instructions,
  799.    with multiple scalar move instructions, or with a library call.
  800.  
  801.    Both X and Y must be MEM rtx's (perhaps inside VOLATILE)
  802.    with mode BLKmode.
  803.    SIZE is an rtx that says how long they are.
  804.    ALIGN is the maximum alignment we can assume they have,
  805.    measured in bytes.  */
  806.  
  807. static void
  808. emit_block_move (x, y, size, align)
  809.      rtx x, y;
  810.      rtx size;
  811.      int align;
  812. {
  813.   if (GET_MODE (x) != BLKmode)
  814.     abort ();
  815.  
  816.   if (GET_MODE (y) != BLKmode)
  817.     abort ();
  818.  
  819.   x = protect_from_queue (x, 1);
  820.   y = protect_from_queue (y, 0);
  821.  
  822.   if (GET_CODE (x) != MEM)
  823.     abort ();
  824.   if (GET_CODE (y) != MEM)
  825.     abort ();
  826.   if (size == 0)
  827.     abort ();
  828.  
  829.   if (GET_CODE (size) == CONST_INT
  830.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  831.       < MOVE_RATIO))
  832.     move_by_pieces (x, y, INTVAL (size), align);
  833.   else
  834.     {
  835. #ifdef HAVE_movstrsi
  836.       if (HAVE_movstrsi)
  837.     {
  838.       emit_insn (gen_movstrsi (x, y, size));
  839.       return;
  840.     }
  841. #endif
  842. #ifdef HAVE_movstrhi
  843.       if (HAVE_movstrhi
  844.       && GET_CODE (size) == CONST_INT
  845.       && ((unsigned) INTVAL (size)
  846.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  847.     {
  848.       emit_insn (gen_movstrhi (x, y, size));
  849.       return;
  850.     }
  851. #endif
  852. #ifdef HAVE_movstrqi
  853.       if (HAVE_movstrqi
  854.       && GET_CODE (size) == CONST_INT
  855.       && ((unsigned) INTVAL (size)
  856.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  857.     {
  858.       emit_insn (gen_movstrqi (x, y, size));
  859.       return;
  860.     }
  861. #endif
  862.  
  863. #ifdef TARGET_MEM_FUNCTIONS
  864.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"),
  865.              VOIDmode, 3, XEXP (x, 0), Pmode,
  866.              XEXP (y, 0), Pmode,
  867.              size, Pmode);
  868. #else
  869.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"),
  870.              VOIDmode, 3, XEXP (y, 0), Pmode,
  871.              XEXP (x, 0), Pmode,
  872.              size, Pmode);
  873. #endif
  874.     }
  875. }
  876.  
  877. /* Copy all or part of a BLKmode value X into registers starting at REGNO.
  878.    The number of registers to be filled is NREGS.  */
  879.  
  880. static void
  881. move_block_to_reg (regno, x, nregs)
  882.      int regno;
  883.      rtx x;
  884.      int nregs;
  885. {
  886.   int i;
  887.   if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx)
  888.     x = force_const_double_mem (x);
  889.   for (i = 0; i < nregs; i++)
  890.     {
  891.       if (GET_CODE (x) == REG)
  892.     emit_move_insn (gen_rtx (REG, SImode, regno + i),
  893.             gen_rtx (SUBREG, SImode, x, i));
  894.       else if (x == dconst0_rtx)
  895.     emit_move_insn (gen_rtx (REG, SImode, regno + i),
  896.             const0_rtx);
  897.       else
  898.     emit_move_insn (gen_rtx (REG, SImode, regno + i),
  899.             gen_rtx (MEM, SImode,
  900.                  plus_constant (XEXP (x, 0),
  901.                         i * GET_MODE_SIZE (SImode))));
  902.     }
  903. }
  904.  
  905. /* Copy all or part of a BLKmode value X out of registers starting at REGNO.
  906.    The number of registers to be filled is NREGS.  */
  907.  
  908. void
  909. move_block_from_reg (regno, x, nregs)
  910.      int regno;
  911.      rtx x;
  912.      int nregs;
  913. {
  914.   int i;
  915.   for (i = 0; i < nregs; i++)
  916.     {
  917.       if (GET_CODE (x) == REG)
  918.     emit_move_insn (gen_rtx (SUBREG, SImode, x, i),
  919.             gen_rtx (REG, SImode, regno + i));
  920.       else
  921.     emit_move_insn (gen_rtx (MEM, SImode,
  922.                  plus_constant (XEXP (x, 0),
  923.                         i * GET_MODE_SIZE (SImode))),
  924.             gen_rtx (REG, SImode, regno + i));
  925.     }
  926. }
  927.  
  928. /* Mark NREGS consecutive regs, starting at REGNO, as being live now.  */
  929.  
  930. static void
  931. use_regs (regno, nregs)
  932.      int regno;
  933.      int nregs;
  934. {
  935.   int i;
  936.   for (i = 0; i < nregs; i++)
  937.     emit_insn (gen_rtx (USE, VOIDmode, gen_rtx (REG, SImode, regno + i)));
  938. }
  939.  
  940. /* Write zeros through the storage of OBJECT.
  941.    If OBJECT has BLKmode, SIZE is its length in bytes.  */
  942.  
  943. void
  944. clear_storage (object, size)
  945.      rtx object;
  946.      int size;
  947. {
  948.   if (GET_MODE (object) == BLKmode)
  949.     {
  950. #ifdef TARGET_MEM_FUNCTIONS
  951.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memset"),
  952.              VOIDmode, 3,
  953.              XEXP (object, 0), Pmode, const0_rtx, Pmode,
  954.              gen_rtx (CONST_INT, VOIDmode, size), Pmode);
  955. #else
  956.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bzero"),
  957.              VOIDmode, 2,
  958.              XEXP (object, 0), Pmode,
  959.              gen_rtx (CONST_INT, VOIDmode, size), Pmode);
  960. #endif
  961.     }
  962.   else
  963.     emit_move_insn (object, const0_rtx, 0);
  964. }
  965.  
  966. /* Generate code to copy Y into X.
  967.    Both Y and X must have the same mode, except that
  968.    Y can be a constant with VOIDmode.
  969.    This mode cannot be BLKmode; use emit_block_move for that.
  970.  
  971.    Return the last instruction emitted.  */
  972.  
  973. rtx
  974. emit_move_insn (x, y)
  975.      rtx x, y;
  976. {
  977.   enum machine_mode mode = GET_MODE (x);
  978.   x = protect_from_queue (x, 1);
  979.   y = protect_from_queue (y, 0);
  980.  
  981.   if ((CONSTANT_P (y) || GET_CODE (y) == CONST_DOUBLE)
  982.       && ! LEGITIMATE_CONSTANT_P (y))
  983.     y = force_const_mem (mode, y);
  984.  
  985.   if (mode == BLKmode)
  986.     abort ();
  987.   if (mov_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  988.     return
  989.       emit_insn (GEN_FCN (mov_optab->handlers[(int) mode].insn_code) (x, y));
  990. #if 0
  991.   /* It turns out you get much better optimization (in cse and flow)
  992.      if you define movdi and movdf instruction patterns
  993.      even if they must turn into multiple assembler instructions.  */
  994.   else if (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (SImode))
  995.     {
  996.       register int count = GET_MODE_SIZE (mode) / GET_MODE_SIZE (SImode);
  997.       register int i;
  998.       if (GET_CODE (y) == CONST_DOUBLE && y != dconst0_rtx)
  999.     y = force_const_double_mem (y);
  1000.       for (i = 0; i < count; i++)
  1001.     {
  1002.       rtx x1, y1;
  1003.       if (GET_CODE (x) == REG)
  1004.         x1 = gen_rtx (SUBREG, SImode, x, i);
  1005.       else
  1006.         x1 = gen_rtx (MEM, SImode,
  1007.               memory_address (SImode,
  1008.                       plus_constant (XEXP (x, 0),
  1009.                              i * GET_MODE_SIZE (SImode))));
  1010.       if (GET_CODE (y) == REG)
  1011.         y1 = gen_rtx (SUBREG, SImode, y, i);
  1012.       else if (y == dconst0_rtx)
  1013.         y1 = const0_rtx;
  1014.       else
  1015.         y1 = gen_rtx (MEM, SImode,
  1016.               memory_address (SImode,
  1017.                       plus_constant (XEXP (y, 0),
  1018.                              i * GET_MODE_SIZE (SImode))));
  1019.       emit_insn (gen_movsi (protect_from_queue (x1, 1), protect_from_queue (y1, 0)));
  1020.     }
  1021.     }
  1022. #endif
  1023.   else
  1024.     abort ();
  1025. }
  1026.  
  1027. /* Pushing data onto the stack.  */
  1028.  
  1029. /* Push a block of length SIZE (perhaps variable)
  1030.    and return an rtx to address the beginning of the block.
  1031.    Note that it is not possible for the value returned to be a QUEUED.
  1032.    The value may be stack_pointer_rtx.
  1033.  
  1034.    The value we return does not take account of STACK_POINTER_OFFSET,
  1035.    so the caller must do so when using the value.  */
  1036.  
  1037. static rtx
  1038. push_block (size)
  1039.      rtx size;
  1040. {
  1041.   register rtx temp;
  1042.   if (CONSTANT_P (size) || GET_CODE (size) == REG)
  1043.     anti_adjust_stack (size);
  1044.   else
  1045.     anti_adjust_stack (copy_to_mode_reg (Pmode, size));
  1046.  
  1047. #ifdef STACK_GROWS_DOWNWARD
  1048.   temp = stack_pointer_rtx;
  1049. #else
  1050.   temp = gen_rtx (PLUS, Pmode,
  1051.           stack_pointer_rtx,
  1052.           size);
  1053.   if (GET_CODE (size) != CONST_INT)
  1054.     temp = force_operand (temp, 0);
  1055. #endif
  1056.   return memory_address (QImode, temp);
  1057. }
  1058.  
  1059. static rtx
  1060. gen_push_operand ()
  1061. {
  1062.   return gen_rtx (
  1063. #ifdef STACK_GROWS_DOWNWARD
  1064.           PRE_DEC,
  1065. #else
  1066.           PRE_INC,
  1067. #endif
  1068.           Pmode,
  1069.           stack_pointer_rtx);
  1070. }
  1071.  
  1072. /* Generate code to push X onto the stack, assuming it has mode MODE.
  1073.    MODE is redundant except when X is a CONST_INT (since they don't
  1074.    carry mode info).
  1075.    SIZE is an rtx for the size of data to be copied (in bytes),
  1076.    needed only if X is BLKmode.
  1077.    ALIGN (in bytes) is maximum alignment we can assume.
  1078.  
  1079.    If PARTIAL is nonzero, then copy that many of the first words
  1080.    of X into registers starting with REG, and push the rest of X.
  1081.    The amount of space pushed is decreased by PARTIAL words,
  1082.    rounded *down* to a multiple of PARM_BOUNDARY.
  1083.    REG must be a hard register in this case.
  1084.  
  1085.    EXTRA is the amount in bytes of extra space to leave next to this arg.
  1086.  
  1087.    On a machine that lacks real push insns, ARGS_ADDR is the address of
  1088.    the bottom of the argument block for this call.  We use indexing off there
  1089.    to store the arg.  On machines with push insns, ARGS_ADDR is 0.
  1090.  
  1091.    ARGS_SO_FAR is the size of args previously pushed for this call.  */
  1092.  
  1093. static void
  1094. emit_push_insn (x, mode, size, align, partial, reg, extra, args_addr, args_so_far)
  1095.      register rtx x;
  1096.      enum machine_mode mode;
  1097.      rtx size;
  1098.      int align;
  1099.      int partial;
  1100.      rtx reg;
  1101.      int extra;
  1102.      rtx args_addr;
  1103.      rtx args_so_far;
  1104. {
  1105.   rtx xinner;
  1106.   enum direction stack_direction
  1107. #ifdef STACK_GROWS_DOWNWARD
  1108.     = downward;
  1109. #else
  1110.     = upward;
  1111. #endif
  1112.  
  1113.   /* Decide where to pad the argument: `downward' for below,
  1114.      `upward' for above, or `none' for don't pad it.
  1115.      Default is below for small data on big-endian machines; else above.  */
  1116.   enum direction where_pad = FUNCTION_ARG_PADDING (mode, size);
  1117.  
  1118.   xinner = x = protect_from_queue (x, 0);
  1119.  
  1120.   /* If part should go in registers, copy that part
  1121.      into the appropriate registers.  */
  1122.   if (partial > 0)
  1123.     move_block_to_reg (REGNO (reg), x, partial);
  1124.  
  1125.   if (extra)
  1126.     {
  1127.       if (args_addr == 0)
  1128.     {
  1129.       /* Push padding now if padding above and stack grows down,
  1130.          or if padding below and stack grows up.  */
  1131.       if (where_pad != none && where_pad != stack_direction)
  1132.         anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
  1133.     }
  1134.       else
  1135.     {
  1136.       /* If space already allocated, just adjust the address we use.  */
  1137.       if (where_pad == downward)
  1138.         args_so_far = plus_constant (args_so_far, extra);
  1139.     }
  1140.     }
  1141.  
  1142.   if (mode == BLKmode)
  1143.     {
  1144.       register rtx temp;
  1145.       int used = partial * UNITS_PER_WORD;
  1146.       int offset = used % (PARM_BOUNDARY / BITS_PER_UNIT);
  1147.  
  1148.       used -= used % (PARM_BOUNDARY / BITS_PER_UNIT);
  1149.  
  1150.       if (size == 0)
  1151.     abort ();
  1152.  
  1153.       if (partial != 0)
  1154.     xinner = change_address (xinner, BLKmode,
  1155.                  plus_constant (XEXP (xinner, 0), used));
  1156.  
  1157. #ifdef PUSH_ROUNDING
  1158.       /* Do it with several push insns if that doesn't take lots of insns
  1159.      and if there is no difficulty with push insns that skip bytes
  1160.      on the stack for alignment purposes.  */
  1161.       if (args_addr == 0
  1162.       && GET_CODE (size) == CONST_INT
  1163.       && args_addr == 0
  1164.       && (move_by_pieces_ninsns ((unsigned) INTVAL (size) - used, align)
  1165.           < MOVE_RATIO)
  1166.       && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size))
  1167.     move_by_pieces (gen_rtx (MEM, BLKmode, gen_push_operand ()), xinner,
  1168.             INTVAL (size) - used, align);
  1169.       else
  1170. #endif /* PUSH_ROUNDING */
  1171.     {
  1172.       /* Otherwise make space on the stack and copy the data
  1173.          to the address of that space.  */
  1174.  
  1175.       /* First deduct part put into registers from the size we need.  */
  1176.       if (partial != 0)
  1177.         {
  1178.           if (GET_CODE (size) == CONST_INT)
  1179.         size = gen_rtx (CONST_INT, VOIDmode, INTVAL (size) - used);
  1180.           else
  1181.         size = expand_binop (GET_MODE (size), sub_optab, size,
  1182.                      gen_rtx (CONST_INT, VOIDmode, used),
  1183.                      0, 0, OPTAB_LIB_WIDEN);
  1184.         }
  1185.  
  1186.       /* Get the address of the stack space.  */
  1187.       if (! args_addr)
  1188.         temp = push_block (size);
  1189.       else if (GET_CODE (args_so_far) == CONST_INT)
  1190.         temp = memory_address (BLKmode,
  1191.                    plus_constant (args_addr,
  1192.                           offset + INTVAL (args_so_far)));
  1193.       else
  1194.         temp = memory_address (BLKmode,
  1195.                    plus_constant (gen_rtx (PLUS, Pmode,
  1196.                                args_addr, args_so_far),
  1197.                           offset));
  1198.  
  1199.  
  1200.       /* TEMP is the address of the block.  Copy the data there.  */
  1201.       if (GET_CODE (size) == CONST_INT
  1202.           && (move_by_pieces_ninsns ((unsigned) INTVAL (size), align)
  1203.           < MOVE_RATIO))
  1204.         {
  1205.           move_by_pieces (gen_rtx (MEM, BLKmode, temp), xinner,
  1206.                   INTVAL (size), align);
  1207.           return;
  1208.         }
  1209. #ifdef HAVE_movstrsi
  1210.       if (HAVE_movstrsi)
  1211.         {
  1212.           emit_insn (gen_movstrsi (gen_rtx (MEM, BLKmode, temp), x, size));
  1213.           return;
  1214.         }
  1215. #endif
  1216. #ifdef HAVE_movstrhi
  1217.       if (HAVE_movstrhi
  1218.           && GET_CODE (size) == CONST_INT
  1219.           && ((unsigned) INTVAL (size)
  1220.           < (1 << (GET_MODE_BITSIZE (HImode) - 1))))
  1221.         {
  1222.           emit_insn (gen_movstrhi (gen_rtx (MEM, BLKmode, temp),
  1223.                        x, size));
  1224.           return;
  1225.         }
  1226. #endif
  1227. #ifdef HAVE_movstrqi
  1228.       if (HAVE_movstrqi
  1229.           && GET_CODE (size) == CONST_INT
  1230.           && ((unsigned) INTVAL (size)
  1231.           < (1 << (GET_MODE_BITSIZE (QImode) - 1))))
  1232.         {
  1233.           emit_insn (gen_movstrqi (gen_rtx (MEM, BLKmode, temp),
  1234.                        x, size));
  1235.           return;
  1236.         }
  1237. #endif
  1238.  
  1239.       if (reg_mentioned_p (stack_pointer_rtx, temp))
  1240.         {
  1241.           /* Correct TEMP so it holds what will be a description of
  1242.          the address to copy to, valid after one arg is pushed.  */
  1243.           int xsize = GET_MODE_SIZE (Pmode);
  1244. #ifdef PUSH_ROUNDING
  1245.           xsize = PUSH_ROUNDING (xsize);
  1246. #endif
  1247.           xsize = ((xsize + PARM_BOUNDARY / BITS_PER_UNIT - 1)
  1248.                / (PARM_BOUNDARY / BITS_PER_UNIT)
  1249.                * (PARM_BOUNDARY / BITS_PER_UNIT));
  1250. #ifdef STACK_GROWS_DOWNWARD
  1251.           temp = plus_constant (temp, xsize);
  1252. #else
  1253.           temp = plus_constant (temp, -xsize);
  1254. #endif
  1255.         }
  1256.  
  1257.       /* Make current_args_size nonzero around the library call
  1258.          to force it to pop the bcopy-arguments right away.  */
  1259.       current_args_size += 1;
  1260. #ifdef TARGET_MEM_FUNCTIONS
  1261.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "memcpy"),
  1262.                  VOIDmode, 3, temp, Pmode, XEXP (xinner, 0), Pmode,
  1263.                  size, Pmode);
  1264. #else
  1265.       emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "bcopy"),
  1266.                  VOIDmode, 3, XEXP (xinner, 0), Pmode, temp, Pmode,
  1267.                  size, Pmode);
  1268. #endif
  1269.       current_args_size -= 1;
  1270.     }
  1271.     }
  1272.   else if (partial > 0)
  1273.     {
  1274.       int size = GET_MODE_SIZE (mode) / UNITS_PER_WORD;
  1275.       int i;
  1276.       int used = partial * UNITS_PER_WORD;
  1277.       /* # words of start of argument
  1278.      that we must make space for but need not store.  */
  1279.       int skip = partial % (PARM_BOUNDARY / BITS_PER_WORD);
  1280.       int args_offset = INTVAL (args_so_far);
  1281.  
  1282.       /* If we make space by pushing it, we might as well push
  1283.      the real data.  Otherwise, we can leave SKIP nonzero
  1284.      and leave the space uninitialized.  */
  1285.       if (args_addr == 0)
  1286.     skip = 0;
  1287.  
  1288.       /* Deduct all the rest of PARTIAL words from SIZE in any case.
  1289.      This is space that we don't even allocate in the stack.  */
  1290.       used -= used % (PARM_BOUNDARY / BITS_PER_UNIT);
  1291.       size -= used / UNITS_PER_WORD;
  1292.  
  1293.       if (GET_CODE (x) == CONST_DOUBLE && x != dconst0_rtx)
  1294.     x = force_const_double_mem (x);
  1295.  
  1296. #ifndef PUSH_ARGS_REVERSED
  1297.       for (i = skip; i < size; i++)
  1298. #else
  1299.       for (i = size - 1; i >= skip; i--)
  1300. #endif
  1301.     if (GET_CODE (x) == MEM)
  1302.       emit_push_insn (gen_rtx (MEM, SImode,
  1303.                    plus_constant (XEXP (x, 0),
  1304.                           i * UNITS_PER_WORD)),
  1305.               SImode, 0, align, 0, 0, 0, args_addr,
  1306.               gen_rtx (CONST_INT, VOIDmode,
  1307.                    args_offset + i * UNITS_PER_WORD));
  1308.     else if (GET_CODE (x) == REG)
  1309.       emit_push_insn (gen_rtx (SUBREG, SImode, x, i),
  1310.               SImode, 0, align, 0, 0, 0, args_addr,
  1311.               gen_rtx (CONST_INT, VOIDmode,
  1312.                    args_offset + i * UNITS_PER_WORD));
  1313.     else if (x == dconst0_rtx)
  1314.       emit_push_insn (const0_rtx,
  1315.               SImode, 0, align, 0, 0, 0, args_addr,
  1316.               gen_rtx (CONST_INT, VOIDmode,
  1317.                    args_offset + i * UNITS_PER_WORD));
  1318.     else
  1319.       abort ();
  1320.     }
  1321.   else
  1322.     {
  1323.       rtx addr;
  1324. #ifdef PUSH_ROUNDING
  1325.       if (args_addr == 0)
  1326.     addr = gen_push_operand ();
  1327.       else
  1328. #endif
  1329.     if (GET_CODE (args_so_far) == CONST_INT)
  1330.       addr
  1331.         = memory_address (mode,
  1332.                   plus_constant (args_addr, INTVAL (args_so_far)));
  1333.       else
  1334.     addr = memory_address (mode, gen_rtx (PLUS, Pmode, args_addr,
  1335.                           args_so_far));
  1336.  
  1337.       emit_move_insn (gen_rtx (MEM, mode, addr), x);
  1338.     }
  1339.  
  1340.   if (extra && args_addr == 0 && where_pad == stack_direction)
  1341.     anti_adjust_stack (gen_rtx (CONST_INT, VOIDmode, extra));
  1342. }
  1343.  
  1344. /* Output a library call to function FUN (a SYMBOL_REF rtx)
  1345.    for a value of mode OUTMODE
  1346.    with NARGS different arguments, passed as alternating rtx values
  1347.    and machine_modes to convert them to.
  1348.    The rtx values should have been passed through protect_from_queue already.  */
  1349.  
  1350. void
  1351. emit_library_call (va_alist)
  1352.      va_dcl
  1353. {
  1354.   register va_list p;
  1355.   register int args_size = 0;
  1356.   register int argnum;
  1357.   enum machine_mode outmode;
  1358.   int nargs;
  1359.   rtx fun;
  1360.   rtx orgfun;
  1361.   int inc;
  1362.   int count;
  1363.   rtx *regvec;
  1364.   rtx argblock = 0;
  1365.   CUMULATIVE_ARGS args_so_far;
  1366.   struct arg { rtx value; enum machine_mode mode; };
  1367.   struct arg *argvec;
  1368.   int old_args_size = current_args_size;
  1369.  
  1370.   va_start (p);
  1371.   orgfun = fun = va_arg (p, rtx);
  1372.   outmode = va_arg (p, enum machine_mode);
  1373.   nargs = va_arg (p, int);
  1374.  
  1375.   regvec = (rtx *) alloca (nargs * sizeof (rtx));
  1376.  
  1377.   /* Copy all the libcall-arguments out of the varargs data
  1378.      and into a vector ARGVEC.  */
  1379.   argvec = (struct arg *) alloca (nargs * sizeof (struct arg));
  1380.   for (count = 0; count < nargs; count++)
  1381.     {
  1382.       argvec[count].value = va_arg (p, rtx);
  1383.       argvec[count].mode = va_arg (p, enum machine_mode);
  1384.     }
  1385.   va_end (p);
  1386.  
  1387.   /* If we have no actual push instructions, make space for all the args
  1388.      right now.  */
  1389. #ifndef PUSH_ROUNDING
  1390.   INIT_CUMULATIVE_ARGS (args_so_far, (tree)0);
  1391.   for (count = 0; count < nargs; count++)
  1392.     {
  1393.       register enum machine_mode mode = argvec[count].mode;
  1394.       register rtx reg;
  1395.       register int partial;
  1396.  
  1397.       reg = FUNCTION_ARG (args_so_far, mode, 0, 1);
  1398. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  1399.       partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, 0, 1);
  1400. #else
  1401.       partial = 0;
  1402. #endif
  1403.       if (reg == 0 || partial != 0)
  1404.     args_size += GET_MODE_SIZE (mode);
  1405.       if (partial != 0)
  1406.     args_size -= partial * GET_MODE_SIZE (SImode);
  1407.       FUNCTION_ARG_ADVANCE (args_so_far, mode, 0, 1);
  1408.     }
  1409.  
  1410.   if (args_size != 0)
  1411.     argblock
  1412.       = push_block (round_push (gen_rtx (CONST_INT, VOIDmode, args_size)));
  1413. #endif
  1414.  
  1415.   INIT_CUMULATIVE_ARGS (args_so_far, (tree)0);
  1416.  
  1417. #ifdef PUSH_ARGS_REVERSED
  1418.   inc = -1;
  1419.   argnum = nargs - 1;
  1420. #else
  1421.   inc = 1;
  1422.   argnum = 0;
  1423. #endif
  1424.   args_size = 0;
  1425.  
  1426.   for (count = 0; count < nargs; count++, argnum += inc)
  1427.     {
  1428.       register enum machine_mode mode = argvec[argnum].mode;
  1429.       register rtx val = argvec[argnum].value;
  1430.       rtx reg;
  1431.       int partial;
  1432.       int arg_size;
  1433.  
  1434.       /* Convert the arg value to the mode the library wants.  */
  1435.       /* ??? It is wrong to do it here; must do it earlier
  1436.      where we know the signedness of the arg.  */
  1437.       if (GET_MODE (val) != mode && GET_MODE (val) != VOIDmode)
  1438.     {
  1439.       val = gen_reg_rtx (mode);
  1440.       convert_move (val, argvec[argnum].value, 0);
  1441.     }
  1442.       reg = FUNCTION_ARG (args_so_far, mode, 0, 1);
  1443.       regvec[argnum] = reg;
  1444. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  1445.       partial = FUNCTION_ARG_PARTIAL_NREGS (args_so_far, mode, 0, 1);
  1446. #else
  1447.       partial = 0;
  1448. #endif
  1449.  
  1450.       if (reg != 0 && partial == 0)
  1451.     emit_move_insn (reg, val);
  1452.       else
  1453.     emit_push_insn (val, mode, 0, 0, partial, reg, 0, argblock,
  1454.             gen_rtx (CONST_INT, VOIDmode, args_size));
  1455.  
  1456.       /* Compute size of stack space used by this argument.  */
  1457.       if (reg == 0 || partial != 0)
  1458.     arg_size = GET_MODE_SIZE (mode);
  1459.       else
  1460.     arg_size = 0;
  1461.       if (partial != 0)
  1462.     arg_size
  1463.       -= ((partial * UNITS_PER_WORD)
  1464.           / (PARM_BOUNDARY / BITS_PER_UNIT)
  1465.           * (PARM_BOUNDARY / BITS_PER_UNIT));
  1466.  
  1467.       args_size += arg_size;
  1468.       current_args_size += arg_size;
  1469.       FUNCTION_ARG_ADVANCE (args_so_far, mode, 0, 1);
  1470.     }
  1471.  
  1472.   emit_queue ();
  1473.  
  1474.   fun = prepare_call_address (fun, 0);
  1475.  
  1476.   /* Any regs containing parms remain in use through the call.
  1477.      ??? This is not quite correct, since it doesn't indicate
  1478.      that they are in use immediately before the call insn.
  1479.      Currently that doesn't matter since explicitly-used regs
  1480.      won't be used for reloading.  But if the reloader becomes smarter,
  1481.      this will have to change somehow.  */
  1482.   for (count = 0; count < nargs; count++)
  1483.     if (regvec[count] != 0)
  1484.       emit_insn (gen_rtx (USE, VOIDmode, regvec[count]));
  1485.  
  1486. #ifdef STACK_BOUNDARY
  1487.   args_size = (args_size + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
  1488. #endif
  1489.  
  1490.   /* Don't allow popping to be deferred, since then
  1491.      cse'ing of library calls could delete a call and leave the pop.  */
  1492.   current_args_size += 1;
  1493.   emit_call_1 (fun, get_identifier (XSTR (orgfun, 0)), args_size,
  1494.            FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
  1495.            outmode != VOIDmode ? hard_libcall_value (outmode) : 0,
  1496.            old_args_size + 1);
  1497.   current_args_size -= 1;
  1498. }
  1499.  
  1500. /* Expand an assignment that stores the value of FROM into TO.
  1501.    If WANT_VALUE is nonzero, return an rtx for the value of TO.
  1502.    (This may contain a QUEUED rtx.)
  1503.    Otherwise, the returned value is not meaningful.
  1504.  
  1505.    SUGGEST_REG is no longer actually used.
  1506.    It used to mean, copy the value through a register
  1507.    and return that register, if that is possible.
  1508.    But now we do this if WANT_VALUE.
  1509.  
  1510.    If the value stored is a constant, we return the constant.  */
  1511.  
  1512. rtx
  1513. expand_assignment (to, from, want_value, suggest_reg)
  1514.      tree to, from;
  1515.      int want_value;
  1516.      int suggest_reg;
  1517. {
  1518.   register rtx to_rtx = 0;
  1519.  
  1520.   /* Don't crash if the lhs of the assignment was erroneous.  */
  1521.  
  1522.   if (TREE_CODE (to) == ERROR_MARK)
  1523.     return expand_expr (from, 0, VOIDmode, 0);
  1524.  
  1525.   /* Assignment of a structure component needs special treatment
  1526.      if the structure component's rtx is not simply a MEM.
  1527.      Assignment of an array element at a constant index
  1528.      has the same problem.  */
  1529.  
  1530.   if (TREE_CODE (to) == COMPONENT_REF
  1531.       || (TREE_CODE (to) == ARRAY_REF
  1532.       && TREE_CODE (TREE_OPERAND (to, 1)) == INTEGER_CST
  1533.       && TREE_CODE (TYPE_SIZE (TREE_TYPE (to))) == INTEGER_CST))
  1534.     {
  1535.       register enum machine_mode mode1;
  1536.       int bitsize;
  1537.       int volstruct = 0;
  1538.       tree tem = to;
  1539.       int bitpos = 0;
  1540.       int unsignedp;
  1541.  
  1542.       if (TREE_CODE (to) == COMPONENT_REF)
  1543.     {
  1544.       tree field = TREE_OPERAND (to, 1);
  1545.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
  1546.       mode1 = DECL_MODE (TREE_OPERAND (to, 1));
  1547.       unsignedp = TREE_UNSIGNED (field);
  1548.     }
  1549.       else
  1550.     {
  1551.       mode1 = TYPE_MODE (TREE_TYPE (to));
  1552.       bitsize = GET_MODE_BITSIZE (mode1);
  1553.       unsignedp = TREE_UNSIGNED (TREE_TYPE (to));
  1554.     }
  1555.  
  1556.       /* Compute cumulative bit-offset for nested component-refs
  1557.      and array-refs, and find the ultimate containing object.  */
  1558.  
  1559.       while (1)
  1560.     {
  1561.       if (TREE_CODE (tem) == COMPONENT_REF)
  1562.         {
  1563.           bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1));
  1564.           if (TREE_THIS_VOLATILE (tem))
  1565.         volstruct = 1;
  1566.         }
  1567.       else if (TREE_CODE (tem) == ARRAY_REF
  1568.            && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
  1569.            && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
  1570.         {
  1571.           bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
  1572.              * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
  1573.              * TYPE_SIZE_UNIT (TREE_TYPE (tem)));
  1574.         }
  1575.       else
  1576.         break;
  1577.       tem = TREE_OPERAND (tem, 0);
  1578.     }
  1579.  
  1580.       /* If we are going to use store_bit_field and extract_bit_field,
  1581.      make sure to_rtx will be safe for multiple use.  */
  1582.       if (mode1 == BImode && want_value)
  1583.     tem = stabilize_reference (tem);
  1584.  
  1585.       to_rtx = expand_expr (tem, 0, VOIDmode, 0);
  1586.  
  1587.       return store_field (to_rtx, bitsize, bitpos, mode1, from,
  1588.               want_value ? TYPE_MODE (TREE_TYPE (to)) : VOIDmode,
  1589.               unsignedp);
  1590.     }
  1591.  
  1592.   /* Ordinary treatment.  Expand TO to get a REG or MEM rtx.
  1593.      Don't re-expand if it was expanded already (in COMPONENT_REF case).  */
  1594.  
  1595.   if (to_rtx == 0)
  1596.     to_rtx = expand_expr (to, 0, VOIDmode, 0);
  1597.  
  1598.   /* Compute FROM and store the value in the rtx we got.  */
  1599.  
  1600.   return store_expr (from, to_rtx, want_value);
  1601. }
  1602.  
  1603. /* Generate code for computing expression EXP,
  1604.    and storing the value into TARGET.
  1605.    Returns TARGET or an equivalent value.
  1606.    TARGET may contain a QUEUED rtx.
  1607.  
  1608.    If SUGGEST_REG is nonzero, copy the value through a register
  1609.    and return that register, if that is possible.
  1610.  
  1611.    If the value stored is a constant, we return the constant.  */
  1612.  
  1613. rtx
  1614. store_expr (exp, target, suggest_reg)
  1615.      register tree exp;
  1616.      register rtx target;
  1617.      int suggest_reg;
  1618. {
  1619.   register rtx temp;
  1620.   int dont_return_target = 0;
  1621.  
  1622.   /* Copying a non-constant CONSTRUCTOR needs special treatment.  */
  1623.  
  1624.   if (TREE_CODE (exp) == CONSTRUCTOR && ! TREE_LITERAL (exp))
  1625.     {
  1626.       store_constructor (exp, target);
  1627.       return target;
  1628.     }
  1629.  
  1630.   if (suggest_reg && GET_CODE (target) == MEM && GET_MODE (target) != BLKmode)
  1631.     /* If target is in memory and caller wants value in a register instead,
  1632.        arrange that.  Pass TARGET as target for expand_expr so that,
  1633.        if EXP is another assignment, SUGGEST_REG will be nonzero for it.
  1634.        We know expand_expr will not use the target in that case.  */
  1635.     {
  1636.       temp = expand_expr (exp, cse_not_expected ? 0 : target,
  1637.               GET_MODE (target), 0);
  1638.       if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
  1639.     temp = copy_to_reg (temp);
  1640.       dont_return_target = 1;
  1641.     }
  1642.   else if (queued_subexp_p (target))
  1643.     /* If target contains a postincrement, it is not safe
  1644.        to use as the returned value.  It would access the wrong
  1645.        place by the time the queued increment gets output.
  1646.        So copy the value through a temporary and use that temp
  1647.        as the result.  */
  1648.     {
  1649.       temp = expand_expr (exp, 0, GET_MODE (target), 0);
  1650.       if (GET_MODE (temp) != BLKmode && GET_MODE (temp) != VOIDmode)
  1651.     temp = copy_to_reg (temp);
  1652.       dont_return_target = 1;
  1653.     }
  1654.   else
  1655.     {
  1656.       temp = expand_expr (exp, target, GET_MODE (target), 0);
  1657.       /* DO return TARGET if it's a specified hardware register.
  1658.      expand_return relies on this.  */
  1659.       if (!(target && GET_CODE (target) == REG
  1660.         && REGNO (target) < FIRST_PSEUDO_REGISTER)
  1661.       && (CONSTANT_P (temp) || GET_CODE (temp) == CONST_DOUBLE))
  1662.     dont_return_target = 1;
  1663.     }
  1664.  
  1665.   /* If value was not generated in the target, store it there.  */
  1666.  
  1667.   if (temp != target && TREE_CODE (exp) != ERROR_MARK)
  1668.     {
  1669.       target = protect_from_queue (target, 1);
  1670.       if (GET_MODE (temp) != GET_MODE (target)
  1671.       && GET_MODE (temp) != VOIDmode)
  1672.     {
  1673.       int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  1674.       if (dont_return_target)
  1675.         temp = convert_to_mode (GET_MODE (target), temp, unsignedp);
  1676.       else
  1677.         convert_move (target, temp, unsignedp);
  1678.     }
  1679.  
  1680.       else if (GET_MODE (temp) == BLKmode)
  1681.     emit_block_move (target, temp, expr_size (exp),
  1682.              TYPE_ALIGN (TREE_TYPE (exp)) / BITS_PER_UNIT);
  1683.       else
  1684.     emit_move_insn (target, temp);
  1685.     }
  1686.   if (dont_return_target)
  1687.     return temp;
  1688.   return target;
  1689. }
  1690.  
  1691. /* Store the value of constructor EXP into the rtx TARGET.
  1692.    TARGET is either a REG or a MEM.  */
  1693.  
  1694. static void
  1695. store_constructor (exp, target)
  1696.      tree exp;
  1697.      rtx target;
  1698. {
  1699.   if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  1700.     {
  1701.       register tree elt;
  1702.  
  1703.       /* If the constructor has fewer fields than the structure,
  1704.      clear the whole structure first.  */
  1705.  
  1706.       if (list_length (CONSTRUCTOR_ELTS (exp))
  1707.       != list_length (TYPE_FIELDS (TREE_TYPE (exp))))
  1708.     clear_storage (target, int_size_in_bytes (TREE_TYPE (exp)));
  1709.       else
  1710.     /* Inform later passes that the old value is dead.  */
  1711.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  1712.  
  1713.       /* Store each element of the constructor into
  1714.      the corresponding field of TARGET.  */
  1715.  
  1716.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  1717.     {
  1718.       register tree field = TREE_PURPOSE (elt);
  1719.       register enum machine_mode mode;
  1720.       int bitsize;
  1721.       int bitpos;
  1722.       int unsignedp;
  1723.  
  1724.       bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
  1725.       mode = DECL_MODE (field);
  1726.       unsignedp = TREE_UNSIGNED (field);
  1727.  
  1728.       bitpos = DECL_OFFSET (field);
  1729.  
  1730.       store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
  1731.                VOIDmode, 0);
  1732.     }
  1733.     }
  1734.   else if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
  1735.     {
  1736.       register tree elt;
  1737.       register int i;
  1738.       tree domain = TYPE_DOMAIN (TREE_TYPE (exp));
  1739.       int minelt = TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain));
  1740.       int maxelt = TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain));
  1741.       tree elttype = TREE_TYPE (TREE_TYPE (exp));
  1742.  
  1743.       /* If the constructor has fewer fields than the structure,
  1744.      clear the whole structure first.  */
  1745.  
  1746.       if (list_length (CONSTRUCTOR_ELTS (exp)) < maxelt - minelt + 1)
  1747.     clear_storage (target, maxelt - minelt + 1);
  1748.       else
  1749.     /* Inform later passes that the old value is dead.  */
  1750.     emit_insn (gen_rtx (CLOBBER, VOIDmode, target));
  1751.  
  1752.       /* Store each element of the constructor into
  1753.      the corresponding element of TARGET, determined
  1754.      by counting the elements.  */
  1755.       for (elt = CONSTRUCTOR_ELTS (exp), i = 0;
  1756.        elt;
  1757.        elt = TREE_CHAIN (elt), i++)
  1758.     {
  1759.       register enum machine_mode mode;
  1760.       int bitsize;
  1761.       int bitpos;
  1762.       int unsignedp;
  1763.  
  1764.       mode = TYPE_MODE (elttype);
  1765.       bitsize = GET_MODE_BITSIZE (mode);
  1766.       unsignedp = TREE_UNSIGNED (elttype);
  1767.  
  1768.       bitpos = (i * TREE_INT_CST_LOW (TYPE_SIZE (elttype))
  1769.             * TYPE_SIZE_UNIT (elttype));
  1770.  
  1771.       store_field (target, bitsize, bitpos, mode, TREE_VALUE (elt),
  1772.                VOIDmode, 0);
  1773.     }
  1774.     }
  1775. }
  1776.  
  1777. /* Store the value of EXP (an expression tree)
  1778.    into a subfield of TARGET which has mode MODE and occupies
  1779.    BITSIZE bits, starting BITPOS bits from the start of TARGET.
  1780.  
  1781.    If VALUE_MODE is VOIDmode, return nothing in particular.
  1782.    UNSIGNEDP is not used in this case.
  1783.  
  1784.    Otherwise, return an rtx for the value stored.  This rtx
  1785.    has mode VALUE_MODE if that is convenient to do.
  1786.    In this case, UNSIGNEDP must be nonzero if the value is an unsigned type.  */
  1787.  
  1788. static rtx
  1789. store_field (target, bitsize, bitpos, mode, exp, value_mode, unsignedp)
  1790.      rtx target;
  1791.      int bitsize, bitpos;
  1792.      enum machine_mode mode;
  1793.      tree exp;
  1794.      enum machine_mode value_mode;
  1795.      int unsignedp;
  1796. {
  1797.   /* If the structure is in a register or if the component
  1798.      is a bit field, we cannot use addressing to access it.
  1799.      Use bit-field techniques or SUBREG to store in it.  */
  1800.  
  1801.   if (mode == BImode || GET_CODE (target) == REG
  1802.       || GET_CODE (target) == SUBREG)
  1803.     {
  1804.       store_bit_field (target, bitsize, bitpos,
  1805.                mode,
  1806.                expand_expr (exp, 0, VOIDmode, 0));
  1807.       if (value_mode != VOIDmode)
  1808.     return extract_bit_field (target, bitsize, bitpos, unsignedp,
  1809.                   0, value_mode, 0);
  1810.       return const0_rtx;
  1811.     }
  1812.   else
  1813.     {
  1814.       rtx addr = XEXP (target, 0);
  1815.       rtx to_rtx;
  1816.  
  1817.       /* If a value is wanted, it must be the lhs;
  1818.      so make the address stable for multiple use.  */
  1819.  
  1820.       if (value_mode != VOIDmode && GET_CODE (addr) != REG
  1821.       && ! CONSTANT_ADDRESS_P (addr))
  1822.     addr = copy_to_reg (addr);
  1823.  
  1824.       /* Now build a reference to just the desired component.  */
  1825.  
  1826.       to_rtx = change_address (target, mode,
  1827.                    plus_constant (addr,
  1828.                           (bitpos / BITS_PER_UNIT)));
  1829.       to_rtx->in_struct = 1;
  1830.  
  1831.       return store_expr (exp, to_rtx, value_mode != VOIDmode);
  1832.     }
  1833. }
  1834.  
  1835. /* Given an rtx VALUE that may contain additions and multiplications,
  1836.    return an equivalent value that just refers to a register or memory.
  1837.    This is done by generating instructions to perform the arithmetic
  1838.    and returning a pseudo-register containing the value.  */
  1839.  
  1840. rtx
  1841. force_operand (value, target)
  1842.      rtx value, target;
  1843. {
  1844.   register optab binoptab = 0;
  1845.   register rtx op2;
  1846.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  1847.   register rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  1848.  
  1849.   if (GET_CODE (value) == PLUS)
  1850.     binoptab = add_optab;
  1851.   else if (GET_CODE (value) == MINUS)
  1852.     binoptab = sub_optab;
  1853.   else if (GET_CODE (value) == MULT)
  1854.     {
  1855.       op2 = XEXP (value, 1);
  1856.       if (!CONSTANT_P (op2)
  1857.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  1858.     subtarget = 0;
  1859.       return expand_mult (GET_MODE (value),
  1860.               force_operand (XEXP (value, 0), subtarget),
  1861.               force_operand (op2, 0),
  1862.               target, 0);
  1863.     }
  1864.  
  1865.   if (binoptab)
  1866.     {
  1867.       op2 = XEXP (value, 1);
  1868.       if (!CONSTANT_P (op2)
  1869.       && !(GET_CODE (op2) == REG && op2 != subtarget))
  1870.     subtarget = 0;
  1871.       if (binoptab == sub_optab
  1872.       && GET_CODE (op2) == CONST_INT && INTVAL (op2) < 0)
  1873.     {
  1874.       binoptab = add_optab;
  1875.       op2 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op2));
  1876.     }
  1877.       return expand_binop (GET_MODE (value), binoptab,
  1878.                force_operand (XEXP (value, 0), subtarget),
  1879.                force_operand (op2, 0),
  1880.                target, 0, OPTAB_LIB_WIDEN);
  1881.       /* We give UNSIGNEP = 0 to expand_binop
  1882.      because the only operations we are expanding here are signed ones.  */
  1883.     }
  1884.   return value;
  1885. }
  1886.  
  1887. /* expand_expr: generate code for computing expression EXP.
  1888.    An rtx for the computed value is returned.
  1889.  
  1890.    The value may be stored in TARGET if TARGET is nonzero.
  1891.    TARGET is just a suggestion; callers must assume that
  1892.    the rtx returned may not be the same as TARGET.
  1893.  
  1894.    If TARGET is CONST0_RTX, it means that the value will be ignored.
  1895.  
  1896.    If TMODE is not VOIDmode, it suggests generating the
  1897.    result in mode TMODE.  But this is done only when convenient.
  1898.    Otherwise, TMODE is ignored and the value generated in its natural mode.
  1899.    TMODE is just a suggestion; callers must assume that
  1900.    the rtx returned may not have mode TMODE.
  1901.  
  1902.    If MODIFIER is EXPAND_SUM then when EXP is an addition
  1903.    we can return an rtx of the form (MULT (REG ...) (CONST_INT ...))
  1904.    or a nest of (PLUS ...) and (MINUS ...) where the terms are
  1905.    products as above, or REG or MEM, or constant.
  1906.    Ordinarily in such cases we would output mul or add instructions
  1907.    and then return a pseudo reg containing the sum.
  1908.  
  1909.    If MODIFIER is EXPAND_CONST_ADDRESS then it is ok to return
  1910.    a MEM rtx whose address is a constant that isn't a legitimate address.  */
  1911.  
  1912. /* Subroutine of expand_expr:
  1913.    return the target to use when recursively expanding
  1914.    the first operand of an arithmetic operation.  */
  1915.  
  1916. static rtx
  1917. validate_subtarget (subtarget, otherop)
  1918.      rtx subtarget;
  1919.      tree otherop;
  1920. {
  1921.   if (TREE_LITERAL (otherop))
  1922.     return subtarget;
  1923.   if (TREE_CODE (otherop) == VAR_DECL
  1924.       && DECL_RTL (otherop) != subtarget)
  1925.     return subtarget;
  1926.   return 0;
  1927. }
  1928.  
  1929. rtx
  1930. expand_expr (exp, target, tmode, modifier)
  1931.      register tree exp;
  1932.      rtx target;
  1933.      enum machine_mode tmode;
  1934.      enum expand_modifier modifier;
  1935. {
  1936.   register rtx op0, op1, temp;
  1937.   tree type = TREE_TYPE (exp);
  1938.   register enum machine_mode mode = TYPE_MODE (type);
  1939.   register enum tree_code code = TREE_CODE (exp);
  1940.   optab this_optab;
  1941.   int negate_1;
  1942.   /* Use subtarget as the target for operand 0 of a binary operation.  */
  1943.   rtx subtarget = (target != 0 && GET_CODE (target) == REG ? target : 0);
  1944.   rtx original_target = target;
  1945.   int ignore = target == const0_rtx;
  1946.  
  1947.   if (ignore) target = 0, original_target = 0;
  1948.  
  1949.   /* If will do cse, generate all results into registers
  1950.      since 1) that allows cse to find more things
  1951.      and 2) otherwise cse could produce an insn the machine
  1952.      cannot support.  */
  1953.  
  1954.   if (! cse_not_expected && mode != BLKmode)
  1955.     target = subtarget;
  1956.  
  1957.   /* No sense saving up arithmetic to be done
  1958.      if it's all in the wrong mode to form part of an address.
  1959.      And force_operand won't know whether to sign-extend or zero-extend.  */
  1960.  
  1961.   if (mode != Pmode && modifier == EXPAND_SUM)
  1962.     modifier = EXPAND_NORMAL;
  1963.  
  1964.   switch (code)
  1965.     {
  1966.     case PARM_DECL:
  1967.       if (DECL_RTL (exp) == 0)
  1968.     {
  1969.       error_with_decl (exp, "prior parameter's size depends on `%s'");
  1970.       return const0_rtx;
  1971.     }
  1972.  
  1973.     case FUNCTION_DECL:
  1974.     case VAR_DECL:
  1975.     case RESULT_DECL:
  1976.       if (DECL_RTL (exp) == 0)
  1977.     abort ();
  1978.       if (GET_CODE (DECL_RTL (exp)) == SYMBOL_REF)
  1979.     abort ();
  1980.       if (GET_CODE (DECL_RTL (exp)) == MEM
  1981.       && modifier != EXPAND_CONST_ADDRESS)
  1982.     {
  1983.       /* DECL_RTL probably contains a constant address.
  1984.          On RISC machines where a constant address isn't valid,
  1985.          make some insns to get that address into a register.  */
  1986.       if (!memory_address_p (DECL_MODE (exp), XEXP (DECL_RTL (exp), 0)))
  1987.         return change_address (DECL_RTL (exp), VOIDmode,
  1988.                    copy_rtx (XEXP (DECL_RTL (exp), 0)));
  1989.     }
  1990.       return DECL_RTL (exp);
  1991.  
  1992.     case INTEGER_CST:
  1993.       return gen_rtx (CONST_INT, VOIDmode, TREE_INT_CST_LOW (exp));
  1994.  
  1995.     case CONST_DECL:
  1996.       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
  1997.  
  1998.     case REAL_CST:
  1999.       /* If optimized, generate immediate CONST_DOUBLE
  2000.      which will be turned into memory by reload if necessary.  */
  2001.       if (!cse_not_expected)
  2002.     return immed_real_const (exp);
  2003.     case COMPLEX_CST:
  2004.     case STRING_CST:
  2005.       if (! TREE_CST_RTL (exp))
  2006.     output_constant_def (exp);
  2007.  
  2008.       /* TREE_CST_RTL probably contains a constant address.
  2009.      On RISC machines where a constant address isn't valid,
  2010.      make some insns to get that address into a register.  */
  2011.       if (GET_CODE (TREE_CST_RTL (exp)) == MEM
  2012.       && modifier != EXPAND_CONST_ADDRESS
  2013.       && !memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0)))
  2014.     return change_address (TREE_CST_RTL (exp), VOIDmode,
  2015.                    copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
  2016.       return TREE_CST_RTL (exp);
  2017.  
  2018.     case SAVE_EXPR:
  2019.       if (SAVE_EXPR_RTL (exp) == 0)
  2020.     {
  2021.       rtx reg = gen_reg_rtx (mode);
  2022.       SAVE_EXPR_RTL (exp) = reg;
  2023.       store_expr (TREE_OPERAND (exp, 0), reg, 0);
  2024.       if (!optimize)
  2025.         save_expr_regs = gen_rtx (EXPR_LIST, VOIDmode, reg,
  2026.                       save_expr_regs);
  2027.     }
  2028.       /* Don't let the same rtl node appear in two places.  */
  2029.       return SAVE_EXPR_RTL (exp);
  2030.  
  2031.     case RTL_EXPR:
  2032.       emit_insn (RTL_EXPR_SEQUENCE (exp));
  2033.       return RTL_EXPR_RTL (exp);
  2034.  
  2035.     case CONSTRUCTOR:
  2036.       /* All elts simple constants => refer to a constant in memory.  */
  2037.       if (TREE_STATIC (exp))
  2038.     /* For aggregate types with non-BLKmode modes,
  2039.        this should ideally construct a CONST_INT.  */
  2040.     return output_constant_def (exp);
  2041.  
  2042.       if (ignore)
  2043.     {
  2044.       tree elt;
  2045.       for (elt = CONSTRUCTOR_ELTS (exp); elt; elt = TREE_CHAIN (elt))
  2046.         expand_expr (TREE_VALUE (elt), const0_rtx, VOIDmode, 0);
  2047.       return const0_rtx;
  2048.     }
  2049.       else
  2050.     {
  2051.       if (target == 0)
  2052.         target = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)),
  2053.                   get_structure_value_addr (expr_size (exp)));
  2054.       store_expr (exp, target, 0);
  2055.       return target;
  2056.     }
  2057.  
  2058.     case INDIRECT_REF:
  2059.       {
  2060.     tree exp1 = TREE_OPERAND (exp, 0);
  2061.     tree exp2;
  2062.  
  2063.     /* A SAVE_EXPR as the address in an INDIRECT_EXPR is generated
  2064.        for  *PTR += ANYTHING  where PTR is put inside the SAVE_EXPR.
  2065.        This code has the same general effect as simply doing
  2066.        expand_expr on the save expr, except that the expression PTR
  2067.        is computed for use as a memory address.  This means different
  2068.        code, suitable for indexing, may be generated.  */
  2069.     if (TREE_CODE (exp1) == SAVE_EXPR
  2070.         && SAVE_EXPR_RTL (exp1) == 0
  2071.         && TREE_CODE (exp2 = TREE_OPERAND (exp1, 0)) != ERROR_MARK
  2072.         && TYPE_MODE (TREE_TYPE (exp1)) == Pmode
  2073.         && TYPE_MODE (TREE_TYPE (exp2)) == Pmode)
  2074.       {
  2075.         temp = expand_expr (TREE_OPERAND (exp1, 0), 0, VOIDmode, EXPAND_SUM);
  2076.         op0 = memory_address (mode, temp);
  2077.         op0 = copy_all_regs (op0);
  2078.         SAVE_EXPR_RTL (exp1) = op0;
  2079.       }
  2080.     else
  2081.       {
  2082.         op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, EXPAND_SUM);
  2083.         op0 = memory_address (mode, op0);
  2084.       }
  2085.       }
  2086.       temp = gen_rtx (MEM, mode, op0);
  2087.       /* If address was computed by addition,
  2088.      mark this as an element of an aggregate.  */
  2089.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == PLUS_EXPR
  2090.       || (TREE_CODE (TREE_OPERAND (exp, 0)) == SAVE_EXPR
  2091.           && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == PLUS_EXPR))
  2092.     temp->in_struct = 1;
  2093.       temp->volatil = TREE_THIS_VOLATILE (exp) | flag_volatile;
  2094.       temp->unchanging = TREE_READONLY (exp);
  2095.       return temp;
  2096.  
  2097.     case ARRAY_REF:
  2098.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST
  2099.       || TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) != INTEGER_CST)
  2100.     {
  2101.       /* Nonconstant array index or nonconstant element size.
  2102.          Generate the tree for *(&array+index) and expand that,
  2103.          except do it in a language-independent way
  2104.          and don't complain about non-lvalue arrays.
  2105.          `mark_addressable' should already have been called
  2106.          for any array for which this case will be reached.  */
  2107.  
  2108.       tree array_adr = build (ADDR_EXPR, TYPE_POINTER_TO (type),
  2109.                   TREE_OPERAND (exp, 0));
  2110.       tree index = TREE_OPERAND (exp, 1);
  2111.       tree elt;
  2112.  
  2113.       /* Convert the integer argument to a type the same size as a pointer
  2114.          so the multiply won't overflow spuriously.  */
  2115.       if (TYPE_PRECISION (TREE_TYPE (index)) != POINTER_SIZE)
  2116.         index = convert (type_for_size (POINTER_SIZE, 0), index);
  2117.  
  2118.       /* The array address isn't volatile even if the array is.  */
  2119.       TREE_VOLATILE (array_adr) = 0;
  2120.  
  2121.       elt = build (INDIRECT_REF, type,
  2122.                fold (build (PLUS_EXPR, TYPE_POINTER_TO (type),
  2123.                     array_adr,
  2124.                     fold (build (MULT_EXPR,
  2125.                          TYPE_POINTER_TO (type),
  2126.                          index, size_in_bytes (type))))));
  2127.  
  2128.       return expand_expr (elt, target, tmode, modifier);
  2129.     }
  2130.       /* Treat array-ref with constant index as a component-ref.  */
  2131.  
  2132.     case COMPONENT_REF:
  2133.       {
  2134.     register enum machine_mode mode1;
  2135.     int volstruct = 0;
  2136.     tree dbg1 = TREE_OPERAND (exp, 0);  /* For debugging */
  2137.     int bitsize;
  2138.     tree tem = exp;
  2139.     int bitpos = 0;
  2140.     int unsignedp;
  2141.  
  2142.     if (TREE_CODE (exp) == COMPONENT_REF)
  2143.       {
  2144.         tree field = TREE_OPERAND (exp, 1);
  2145.         bitsize = TREE_INT_CST_LOW (DECL_SIZE (field)) * DECL_SIZE_UNIT (field);
  2146.         mode1 = DECL_MODE (TREE_OPERAND (exp, 1));
  2147.         unsignedp = TREE_UNSIGNED (field);
  2148.       }
  2149.     else
  2150.       {
  2151.         mode1 = TYPE_MODE (TREE_TYPE (exp));
  2152.         bitsize = GET_MODE_BITSIZE (mode1);
  2153.         unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2154.       }
  2155.  
  2156.     /* Compute cumulative bit-offset for nested component-refs
  2157.        and array-refs, and find the ultimate containing object.  */
  2158.  
  2159.     while (1)
  2160.       {
  2161.         if (TREE_CODE (tem) == COMPONENT_REF)
  2162.           {
  2163.         bitpos += DECL_OFFSET (TREE_OPERAND (tem, 1));
  2164.         if (TREE_THIS_VOLATILE (tem))
  2165.           volstruct = 1;
  2166.           }
  2167.         else if (TREE_CODE (tem) == ARRAY_REF
  2168.              && TREE_CODE (TREE_OPERAND (tem, 1)) == INTEGER_CST
  2169.              && TREE_CODE (TYPE_SIZE (TREE_TYPE (tem))) == INTEGER_CST)
  2170.           {
  2171.         bitpos += (TREE_INT_CST_LOW (TREE_OPERAND (tem, 1))
  2172.                * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tem)))
  2173.                * TYPE_SIZE_UNIT (TREE_TYPE (tem)));
  2174.           }
  2175.         else
  2176.           break;
  2177.         tem = TREE_OPERAND (tem, 0);
  2178.       }
  2179.  
  2180.     op0 = expand_expr (tem, 0, VOIDmode,
  2181.                (modifier == EXPAND_CONST_ADDRESS
  2182.                 ? modifier : EXPAND_NORMAL));
  2183.  
  2184.     if (mode1 == BImode || GET_CODE (op0) == REG
  2185.         || GET_CODE (op0) == SUBREG)
  2186.       {
  2187.         return extract_bit_field (op0, bitsize, bitpos, unsignedp,
  2188.                       target, mode, tmode);
  2189.       }
  2190.     /* Get a reference to just this component.  */
  2191.     if (modifier == EXPAND_CONST_ADDRESS)
  2192.       op0 = gen_rtx (MEM, mode1, plus_constant (XEXP (op0, 0),
  2193.                             (bitpos / BITS_PER_UNIT)));
  2194.     else
  2195.       op0 = change_address (op0, mode1,
  2196.                 plus_constant (XEXP (op0, 0),
  2197.                            (bitpos / BITS_PER_UNIT)));
  2198.     op0->in_struct = 1;
  2199.     op0->volatil = volstruct;
  2200.     /* If OP0 is in the shared structure-value stack slot,
  2201.        and it is not BLKmode, copy it into a register.
  2202.        The shared slot may be clobbered at any time by another call.
  2203.        BLKmode is safe because our caller will either copy the value away
  2204.        or take another component and come back here.  */
  2205.     if (mode != BLKmode
  2206.         && TREE_CODE (TREE_OPERAND (exp, 0)) == CALL_EXPR
  2207.         && TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == BLKmode)
  2208.       op0 = copy_to_reg (op0);
  2209.     if (mode == mode1 || mode1 == BLKmode || mode1 == tmode)
  2210.       return op0;
  2211.     if (target == 0)
  2212.       target = gen_reg_rtx (tmode != VOIDmode ? tmode : mode);
  2213.     convert_move (target, op0, unsignedp);
  2214.     return target;
  2215.       }
  2216.  
  2217.       /* Intended for a reference to a buffer of a file-object in Pascal.
  2218.      But it's not certain that a special tree code will really be
  2219.      necessary for these.  INDIRECT_REF might work for them.  */
  2220.     case BUFFER_REF:
  2221.       abort ();
  2222.  
  2223.     case CALL_EXPR:
  2224.       /* Check for a built-in function.  */
  2225.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  2226.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
  2227.       && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  2228.           != NOT_BUILT_IN))
  2229.     return expand_builtin (exp, target, subtarget, tmode);
  2230.       /* If this call was expanded already by preexpand_calls,
  2231.      just return the result we got.  */
  2232.       if (CALL_EXPR_RTL (exp) != 0)
  2233.     return CALL_EXPR_RTL (exp);
  2234.       return expand_call (exp, target, ignore);
  2235.  
  2236.     case NOP_EXPR:
  2237.     case CONVERT_EXPR:
  2238.       if (TREE_CODE (type) == VOID_TYPE || ignore)
  2239.     {
  2240.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, modifier);
  2241.       return const0_rtx;
  2242.     }
  2243.       if (mode == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))
  2244.     return expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, modifier);
  2245.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, mode, 0);
  2246.       if (GET_MODE (op0) == mode || GET_MODE (op0) == VOIDmode)
  2247.     return op0;
  2248.       if (flag_force_mem && GET_CODE (op0) == MEM)
  2249.     op0 = copy_to_reg (op0);
  2250.       if (target == 0)
  2251.     target = gen_reg_rtx (mode);
  2252.       convert_move (target, op0, TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))));
  2253.       return target;
  2254.  
  2255.     case PLUS_EXPR:
  2256.       preexpand_calls (exp);
  2257.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST
  2258.       && modifier == EXPAND_SUM)
  2259.     {
  2260.       op1 = expand_expr (TREE_OPERAND (exp, 1), subtarget, VOIDmode, EXPAND_SUM);
  2261.       op1 = plus_constant (op1, TREE_INT_CST_LOW (TREE_OPERAND (exp, 0)));
  2262.       return op1;
  2263.     }
  2264.       negate_1 = 1;
  2265.     plus_minus:
  2266.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  2267.       && modifier == EXPAND_SUM)
  2268.     {
  2269.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  2270.       op0 = plus_constant (op0,
  2271.                    negate_1 * TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
  2272.       return op0;
  2273.     }
  2274.       this_optab = add_optab;
  2275.       if (modifier != EXPAND_SUM) goto binop;
  2276.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2277.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  2278.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, EXPAND_SUM);
  2279.       /* Put a sum last, to simplify what follows.  */
  2280. #ifdef OLD_INDEXING
  2281.       if (GET_CODE (op1) == MULT)
  2282.     {
  2283.       temp = op0;
  2284.       op0 = op1;
  2285.       op1 = temp;
  2286.     }
  2287. #endif
  2288. #ifndef OLD_INDEXING
  2289.       /* Make sure any term that's a sum with a constant comes last.  */
  2290.       if (GET_CODE (op0) == PLUS
  2291.       && CONSTANT_P (XEXP (op0, 1)))
  2292.     {
  2293.       temp = op0;
  2294.       op0 = op1;
  2295.       op1 = temp;
  2296.     }
  2297.       /* If adding to a sum including a constant,
  2298.      associate it to put the constant outside.  */
  2299.       if (GET_CODE (op1) == PLUS
  2300.       && CONSTANT_P (XEXP (op1, 1)))
  2301.     {
  2302.       op0 = gen_rtx (PLUS, mode, XEXP (op1, 0), op0);
  2303.       if (GET_CODE (XEXP (op1, 1)) == CONST_INT)
  2304.         return plus_constant (op0, INTVAL (XEXP (op1, 1)));
  2305.       else
  2306.         return gen_rtx (PLUS, mode, op0, XEXP (op1, 1));
  2307.     }
  2308. #endif
  2309.       return gen_rtx (PLUS, mode, op0, op1);
  2310.  
  2311.     case MINUS_EXPR:
  2312.       preexpand_calls (exp);
  2313.       if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  2314.     {
  2315.       if (modifier == EXPAND_SUM)
  2316.         {
  2317.           negate_1 = -1;
  2318.           goto plus_minus;
  2319.         }
  2320.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2321.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2322.       op1 = gen_rtx (CONST_INT, VOIDmode,
  2323.              - TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)));
  2324.       this_optab = add_optab;
  2325.       goto binop2;
  2326.     }
  2327.       this_optab = sub_optab;
  2328.       goto binop;
  2329.  
  2330.     case MULT_EXPR:
  2331.       preexpand_calls (exp);
  2332.       /* If first operand is constant, swap them.
  2333.      Thus the following special case checks need only
  2334.      check the second operand.  */
  2335.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST)
  2336.     {
  2337.       register tree t1 = TREE_OPERAND (exp, 0);
  2338.       TREE_OPERAND (exp, 0) = TREE_OPERAND (exp, 1);
  2339.       TREE_OPERAND (exp, 1) = t1;
  2340.     }
  2341.  
  2342.       /* Attempt to return something suitable for generating an
  2343.      indexed address, for machines that support that.  */
  2344.  
  2345.       if (modifier == EXPAND_SUM
  2346.       && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  2347.     {
  2348.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, EXPAND_SUM);
  2349.  
  2350.       /* Apply distributive law if OP0 is x+c.  */
  2351.       if (GET_CODE (op0) == PLUS
  2352.           && GET_CODE (XEXP (op0, 1)) == CONST_INT)
  2353.         return gen_rtx (PLUS, mode,
  2354.                 gen_rtx (MULT, mode, XEXP (op0, 0),
  2355.                      gen_rtx (CONST_INT, VOIDmode,
  2356.                           TREE_INT_CST_LOW (TREE_OPERAND (exp, 1)))),
  2357.                 gen_rtx (CONST_INT, VOIDmode,
  2358.                      (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))
  2359.                       * INTVAL (XEXP (op0, 1)))));
  2360.  
  2361.       if (GET_CODE (op0) != REG)
  2362.         op0 = force_operand (op0, 0);
  2363.       if (GET_CODE (op0) != REG)
  2364.         op0 = copy_to_mode_reg (mode, op0);
  2365.  
  2366.       return gen_rtx (MULT, mode, op0,
  2367.               gen_rtx (CONST_INT, VOIDmode,
  2368.                    TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))));
  2369.     }
  2370.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2371.       /* Check for multiplying things that have been extended
  2372.      from a narrower type.  If this machine supports multiplying
  2373.      in that narrower type with a result in the desired type,
  2374.      do it that way, and avoid the explicit type-conversion.  */
  2375.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == NOP_EXPR
  2376.       && TREE_CODE (TREE_TYPE (exp)) == INTEGER_TYPE
  2377.       && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  2378.           < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))
  2379.       && ((TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST
  2380.            && int_fits_type_p (TREE_OPERAND (exp, 1),
  2381.                    TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  2382.            /* Don't use a widening multiply if a shift will do.  */
  2383.            && exact_log2 (TREE_INT_CST_LOW (TREE_OPERAND (exp, 1))) < 0)
  2384.           ||
  2385.           (TREE_CODE (TREE_OPERAND (exp, 1)) == NOP_EXPR
  2386.            && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  2387.            ==
  2388.            TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))))
  2389.            /* If both operands are extended, they must either both
  2390.           be zero-extended or both be sign-extended.  */
  2391.            && (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 1), 0)))
  2392.            ==
  2393.            TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))))))
  2394.     {
  2395.       enum machine_mode innermode
  2396.         = TYPE_MODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)));
  2397.       this_optab = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)))
  2398.             ? umul_widen_optab : smul_widen_optab);
  2399.       if ((int) innermode + 1 == (int) mode
  2400.           && this_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
  2401.         {
  2402.           op0 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 0), 0),
  2403.                  0, VOIDmode, 0);
  2404.           if (TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST)
  2405.         op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2406.           else
  2407.         op1 = expand_expr (TREE_OPERAND (TREE_OPERAND (exp, 1), 0),
  2408.                    0, VOIDmode, 0);
  2409.           goto binop2;
  2410.         }
  2411.     }
  2412.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2413.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2414.       return expand_mult (mode, op0, op1, target, TREE_UNSIGNED (type));
  2415.  
  2416.     case TRUNC_DIV_EXPR:
  2417.     case FLOOR_DIV_EXPR:
  2418.     case CEIL_DIV_EXPR:
  2419.     case ROUND_DIV_EXPR:
  2420.       preexpand_calls (exp);
  2421.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2422.       /* Possible optimization: compute the dividend with EXPAND_SUM
  2423.      then if the divisor is constant can optimize the case
  2424.      where some terms of the dividend have coeffs divisible by it.  */
  2425.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2426.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2427.       return expand_divmod (0, code, mode, op0, op1, target,
  2428.                 TREE_UNSIGNED (type));
  2429.  
  2430.     case RDIV_EXPR:
  2431.       preexpand_calls (exp);
  2432.       this_optab = flodiv_optab;
  2433.       goto binop;
  2434.  
  2435.     case TRUNC_MOD_EXPR:
  2436.     case FLOOR_MOD_EXPR:
  2437.     case CEIL_MOD_EXPR:
  2438.     case ROUND_MOD_EXPR:
  2439.       preexpand_calls (exp);
  2440.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2441.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2442.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2443.       return expand_divmod (1, code, mode, op0, op1, target,
  2444.                 TREE_UNSIGNED (type));
  2445. #if 0
  2446. #ifdef HAVE_divmoddisi4
  2447.       if (GET_MODE (op0) != DImode)
  2448.     {
  2449.       temp = gen_reg_rtx (DImode);
  2450.       convert_move (temp, op0, 0);
  2451.       op0 = temp;
  2452.       if (GET_MODE (op1) != SImode && GET_CODE (op1) != CONST_INT)
  2453.         {
  2454.           temp = gen_reg_rtx (SImode);
  2455.           convert_move (temp, op1, 0);
  2456.           op1 = temp;
  2457.         }
  2458.       temp = gen_reg_rtx (SImode);
  2459.       if (target == 0)
  2460.         target = gen_reg_rtx (SImode);
  2461.       emit_insn (gen_divmoddisi4 (temp, protect_from_queue (op0, 0),
  2462.                       protect_from_queue (op1, 0),
  2463.                       protect_from_queue (target, 1)));
  2464.       return target;
  2465.     }
  2466. #endif
  2467. #endif
  2468.  
  2469.     case FIX_ROUND_EXPR:
  2470.     case FIX_FLOOR_EXPR:
  2471.     case FIX_CEIL_EXPR:
  2472.       abort ();            /* Not used for C.  */
  2473.  
  2474.     case FIX_TRUNC_EXPR:
  2475.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  2476.       if (target == 0)
  2477.     target = gen_reg_rtx (mode);
  2478.       {
  2479.     int unsignedp = TREE_UNSIGNED (TREE_TYPE (exp));
  2480.     if (mode == HImode || mode == QImode)
  2481.       {
  2482.         register rtx temp = gen_reg_rtx (SImode);
  2483.         expand_fix (temp, op0, 0);
  2484.         convert_move (target, temp, 0);
  2485.       }
  2486.     else
  2487.       expand_fix (target, op0, unsignedp);
  2488.       }
  2489.       return target;
  2490.  
  2491.     case FLOAT_EXPR:
  2492.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  2493.       if (target == 0)
  2494.     target = gen_reg_rtx (mode);
  2495.       {
  2496.     int unsignedp = TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)));
  2497.     if (GET_MODE (op0) == HImode
  2498.         || GET_MODE (op0) == QImode)
  2499.       {
  2500.         register rtx temp = gen_reg_rtx (SImode);
  2501.         convert_move (temp, op0, unsignedp);
  2502.         expand_float (target, temp, 0);
  2503.       }
  2504.     else
  2505.       expand_float (target, op0, unsignedp);
  2506.       }
  2507.       return target;
  2508.  
  2509.     case NEGATE_EXPR:
  2510.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  2511.       temp = expand_unop (mode, neg_optab, op0, target, 0);
  2512.       if (temp == 0)
  2513.     abort ();
  2514.       return temp;
  2515.  
  2516.     case ABS_EXPR:
  2517.       /* First try to do it with a special abs instruction.
  2518.      If that does not win, use conditional jump and negate.  */
  2519.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2520.       temp = expand_unop (mode, abs_optab, op0, target, 0);
  2521.       if (temp != 0)
  2522.     return temp;
  2523.       temp = gen_label_rtx ();
  2524.       if (target == 0 || GET_CODE (target) != REG)
  2525.     target = gen_reg_rtx (mode);
  2526.       emit_move_insn (target, op0);
  2527.       emit_cmp_insn (target,
  2528.              expand_expr (convert (TREE_TYPE (exp), integer_zero_node),
  2529.                   0, VOIDmode, 0),
  2530.              0, 0);
  2531.       NO_DEFER_POP;
  2532.       emit_jump_insn (gen_bge (temp));
  2533.       op0 = expand_unop (mode, neg_optab, target, target, 0);
  2534.       if (op0 != target)
  2535.     emit_move_insn (target, op0);
  2536.       emit_label (temp);
  2537.       OK_DEFER_POP;
  2538.       return target;
  2539.  
  2540.     case MAX_EXPR:
  2541.     case MIN_EXPR:
  2542.       mode = TYPE_MODE (TREE_OPERAND (exp, 1));
  2543.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2544.       if (target == 0 || GET_CODE (target) != REG || target == op1)
  2545.     target = gen_reg_rtx (mode);
  2546.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  2547.       if (target != op0)
  2548.     emit_move_insn (target, op0);
  2549.       op0 = gen_label_rtx ();
  2550.       if (code == MAX_EXPR)
  2551.     temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  2552.         ? compare1 (target, op1, GEU, LEU, 1, mode)
  2553.         : compare1 (target, op1, GE, LE, 0, mode));
  2554.       else
  2555.     temp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1)))
  2556.         ? compare1 (target, op1, LEU, GEU, 1, mode)
  2557.         : compare1 (target, op1, LE, GE, 0, mode));
  2558.       if (temp == const0_rtx)
  2559.     emit_move_insn (target, op1);
  2560.       else if (temp != const1_rtx)
  2561.     {
  2562.       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
  2563.                    gen_rtx (IF_THEN_ELSE, VOIDmode,
  2564.                         temp,
  2565.                         gen_rtx (LABEL_REF, VOIDmode, op0),
  2566.                         pc_rtx)));
  2567.       emit_move_insn (target, op1);
  2568.     }
  2569.       emit_label (op0);
  2570.       return target;
  2571.  
  2572. /* ??? Can optimize when the operand of this is a bitwise operation,
  2573.    by using a different bitwise operation.  */
  2574.     case BIT_NOT_EXPR:
  2575.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2576.       temp = expand_unop (mode, one_cmpl_optab, op0, target, 1);
  2577.       if (temp == 0)
  2578.     abort ();
  2579.       return temp;
  2580.  
  2581.     case FFS_EXPR:
  2582.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2583.       temp = expand_unop (mode, ffs_optab, op0, target, 1);
  2584.       if (temp == 0)
  2585.     abort ();
  2586.       return temp;
  2587.  
  2588. /* ??? Can optimize bitwise operations with one arg constant.
  2589.    Pastel optimizes (a bitwise1 n) bitwise2 (a bitwise3 b)
  2590.    and (a bitwise1 b) bitwise2 b (etc)
  2591.    but that is probably not worth while.  */
  2592.  
  2593. /* BIT_AND_EXPR is for bitwise anding.
  2594.    TRUTH_AND_EXPR is for anding two boolean values
  2595.    when we want in all cases to compute both of them.
  2596.    In general it is fastest to do TRUTH_AND_EXPR by
  2597.    computing both operands as actual zero-or-1 values
  2598.    and then bitwise anding.  In cases where there cannot
  2599.    be any side effects, better code would be made by
  2600.    treating TRUTH_AND_EXPR like TRUTH_ANDIF_EXPR;
  2601.    but the question is how to recognize those cases.  */
  2602.  
  2603.     case TRUTH_AND_EXPR:
  2604.     case BIT_AND_EXPR:
  2605.       preexpand_calls (exp);
  2606.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2607.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2608.       op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2609.       return expand_bit_and (mode, op0, op1, target);
  2610.  
  2611. /* See comment above about TRUTH_AND_EXPR; it applies here too.  */
  2612.     case TRUTH_OR_EXPR:
  2613.     case BIT_IOR_EXPR:
  2614.       preexpand_calls (exp);
  2615.       this_optab = ior_optab;
  2616.       goto binop;
  2617.  
  2618.     case BIT_XOR_EXPR:
  2619.       preexpand_calls (exp);
  2620.       this_optab = xor_optab;
  2621.       goto binop;
  2622.  
  2623.     case LSHIFT_EXPR:
  2624.     case RSHIFT_EXPR:
  2625.     case LROTATE_EXPR:
  2626.     case RROTATE_EXPR:
  2627.       preexpand_calls (exp);
  2628.       subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2629.       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2630.       return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
  2631.                TREE_UNSIGNED (type));
  2632.  
  2633. /* ??? cv's were used to effect here to combine additive constants
  2634.    and to determine the answer when only additive constants differ.
  2635.    Also, the addition of one can be handled by changing the condition.  */
  2636.     case LT_EXPR:
  2637.     case LE_EXPR:
  2638.     case GT_EXPR:
  2639.     case GE_EXPR:
  2640.     case EQ_EXPR:
  2641.     case NE_EXPR:
  2642.       preexpand_calls (exp);
  2643.       temp = do_store_flag (exp, target, mode);
  2644.       if (temp != 0)
  2645.     return temp;
  2646.       /* For foo != 0, load foo, and if it is nonzero load 1 instead. */
  2647.       if (code == NE_EXPR && integer_zerop (TREE_OPERAND (exp, 1))
  2648.       && subtarget
  2649.       && (GET_MODE (subtarget)
  2650.           == TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))))
  2651.     {
  2652.       temp = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2653.       if (temp != subtarget)
  2654.         temp = copy_to_reg (temp);
  2655.       op1 = gen_label_rtx ();
  2656.       emit_cmp_insn (temp, const0_rtx, 0, TREE_UNSIGNED (type));
  2657.       emit_jump_insn (gen_beq (op1));
  2658.       emit_move_insn (temp, const1_rtx);
  2659.       emit_label (op1);
  2660.       return temp;
  2661.     }
  2662.       /* If no set-flag instruction, must generate a conditional
  2663.      store into a temporary variable.  Drop through
  2664.      and handle this like && and ||.  */
  2665.  
  2666.     case TRUTH_ANDIF_EXPR:
  2667.     case TRUTH_ORIF_EXPR:
  2668.       temp = gen_reg_rtx (mode);
  2669.       emit_clr_insn (temp);
  2670.       op1 = gen_label_rtx ();
  2671.       jumpifnot (exp, op1);
  2672.       emit_0_to_1_insn (temp);
  2673.       emit_label (op1);
  2674.       return temp;
  2675.  
  2676.     case TRUTH_NOT_EXPR:
  2677.       op0 = expand_expr (TREE_OPERAND (exp, 0), target, VOIDmode, 0);
  2678.       /* The parser is careful to generate TRUTH_NOT_EXPR
  2679.      only with operands that are always zero or one.  */
  2680.       temp = expand_binop (mode, xor_optab, op0,
  2681.                gen_rtx (CONST_INT, mode, 1),
  2682.                target, 1, OPTAB_LIB_WIDEN);
  2683.       if (temp == 0)
  2684.     abort ();
  2685.       return temp;
  2686.  
  2687.     case COMPOUND_EXPR:
  2688.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  2689.       emit_queue ();
  2690.       return expand_expr (TREE_OPERAND (exp, 1), target, VOIDmode, 0);
  2691.  
  2692.     case COND_EXPR:
  2693.       /* Note that COND_EXPRs whose type is a structure or union
  2694.      are required to be constructed to contain assignments of
  2695.      a temporary variable, so that we can evaluate them here
  2696.      for side effect only.  If type is void, we must do likewise.  */
  2697.       op0 = gen_label_rtx ();
  2698.       op1 = gen_label_rtx ();
  2699.  
  2700.       if (mode == VOIDmode || ignore)
  2701.     temp = 0;
  2702.       else if (target)
  2703.     temp = target;
  2704.       else if (mode == BLKmode)
  2705.     {
  2706.       if (TYPE_SIZE (type) == 0 || ! TREE_LITERAL (TYPE_SIZE (type)))
  2707.         abort ();
  2708.       temp = assign_stack_local (BLKmode,
  2709.                      (TREE_INT_CST_LOW (TYPE_SIZE (type))
  2710.                       * TYPE_SIZE_UNIT (type)
  2711.                       + BITS_PER_UNIT - 1)
  2712.                      / BITS_PER_UNIT);
  2713.     }
  2714.       else
  2715.     temp = gen_reg_rtx (mode);
  2716.  
  2717.       jumpifnot (TREE_OPERAND (exp, 0), op0);
  2718.       NO_DEFER_POP;
  2719.       if (temp != 0)
  2720.     store_expr (TREE_OPERAND (exp, 1), temp, 0);
  2721.       else
  2722.     expand_expr (TREE_OPERAND (exp, 1), ignore ? const0_rtx : 0,
  2723.              VOIDmode, 0);
  2724.       emit_queue ();
  2725.       emit_jump_insn (gen_jump (op1));
  2726.       emit_barrier ();
  2727.       emit_label (op0);
  2728.       if (temp != 0)
  2729.     store_expr (TREE_OPERAND (exp, 2), temp, 0);
  2730.       else
  2731.     expand_expr (TREE_OPERAND (exp, 2), ignore ? const0_rtx : 0,
  2732.              VOIDmode, 0);
  2733.       emit_queue ();
  2734.       emit_label (op1);
  2735.       OK_DEFER_POP;
  2736.       return temp;
  2737.  
  2738.     case MODIFY_EXPR:
  2739.       /* If lhs is complex, expand calls in rhs before computing it.
  2740.      That's so we don't compute a pointer and save it over a call.
  2741.      If lhs is simple, compute it first so we can give it as a
  2742.      target if the rhs is just a call.  This avoids an extra temp and copy
  2743.      and that prevents a partial-subsumption which makes bad code.
  2744.      Actually we could treat component_ref's of vars like vars.  */
  2745.       if (TREE_CODE (TREE_OPERAND (exp, 0)) != VAR_DECL
  2746.       && TREE_CODE (TREE_OPERAND (exp, 0)) != RESULT_DECL
  2747.       && TREE_CODE (TREE_OPERAND (exp, 0)) != PARM_DECL)
  2748.     preexpand_calls (exp);
  2749.       temp = expand_assignment (TREE_OPERAND (exp, 0),
  2750.                 TREE_OPERAND (exp, 1),
  2751.                 ! ignore,
  2752.                 original_target != 0);
  2753.       return temp;
  2754.  
  2755.     case PREINCREMENT_EXPR:
  2756.     case PREDECREMENT_EXPR:
  2757.       return expand_increment (exp, 0);
  2758.  
  2759.     case POSTINCREMENT_EXPR:
  2760.     case POSTDECREMENT_EXPR:
  2761.       return expand_increment (exp, 1);
  2762.  
  2763.     case ADDR_EXPR:
  2764.       op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode,
  2765.              EXPAND_CONST_ADDRESS);
  2766.       if (GET_CODE (op0) != MEM)
  2767.     abort ();
  2768.       if (modifier == EXPAND_SUM)
  2769.     return XEXP (op0, 0);
  2770.       op0 = force_operand (XEXP (op0, 0), target);
  2771.       if (flag_force_addr && GET_CODE (op0) != REG)
  2772.     return force_reg (Pmode, op0);
  2773.       return op0;
  2774.  
  2775.     case ENTRY_VALUE_EXPR:
  2776.       abort ();
  2777.  
  2778.     case ERROR_MARK:
  2779.       return const0_rtx;
  2780.  
  2781.     default:
  2782.       abort ();
  2783.     }
  2784.  
  2785.   /* Here to do an ordinary binary operator, generating an instruction
  2786.      from the optab already placed in `this_optab'.  */
  2787.  binop:
  2788.   /* Detect things like x = y | (a == b)
  2789.      and do them as (x = y), (a == b ? x |= 1 : 0), x.  */
  2790.   /* First, get the comparison or conditional into the second arg.  */
  2791.   if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 0))]
  2792.       || (TREE_CODE (TREE_OPERAND (exp, 0)) == COND_EXPR
  2793.       && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 1))
  2794.           || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 0), 2)))))
  2795.     {
  2796.       if (this_optab == ior_optab || this_optab == add_optab
  2797.       || this_optab == xor_optab)
  2798.     {
  2799.       tree exch = TREE_OPERAND (exp, 1);
  2800.       TREE_OPERAND (exp, 1) = TREE_OPERAND (exp, 0);
  2801.       TREE_OPERAND (exp, 0) = exch;
  2802.     }
  2803.     }
  2804.   /* Optimize X + (Y ? Z : 0) by computing X and maybe adding Z.  */
  2805.   if (comparison_code[(int) TREE_CODE (TREE_OPERAND (exp, 1))]
  2806.       || (TREE_CODE (TREE_OPERAND (exp, 1)) == COND_EXPR
  2807.       && (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 1))
  2808.           || integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2)))))
  2809.     {
  2810.       if (this_optab == ior_optab || this_optab == add_optab
  2811.       || this_optab == xor_optab || this_optab == sub_optab
  2812.       || this_optab == lshl_optab || this_optab == ashl_optab
  2813.       || this_optab == lshr_optab || this_optab == ashr_optab
  2814.       || this_optab == rotl_optab || this_optab == rotr_optab)
  2815.     {
  2816.       tree thenexp;
  2817.       rtx thenv = 0;
  2818.  
  2819.       /* Don't store intermediate results in a fixed register.  */
  2820.       if (target != 0 && GET_CODE (target) == REG
  2821.           && REGNO (target) < FIRST_PSEUDO_REGISTER)
  2822.         target = 0;
  2823.       if (target == 0) target = gen_reg_rtx (mode);
  2824.  
  2825.       /* Compute X into the target.  */
  2826.       store_expr (TREE_OPERAND (exp, 0), target, 0);
  2827.       op0 = gen_label_rtx ();
  2828.  
  2829.       /* If other operand is a comparison COMP, treat it as COMP ? 1 : 0 */
  2830.       if (TREE_CODE (TREE_OPERAND (exp, 1)) != COND_EXPR)
  2831.         {
  2832.           do_jump (TREE_OPERAND (exp, 1), op0, 0);
  2833.           thenv = const1_rtx;
  2834.         }
  2835.       else if (integer_zerop (TREE_OPERAND (TREE_OPERAND (exp, 1), 2)))
  2836.         {
  2837.           do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), op0, 0);
  2838.           thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 1);
  2839.         }
  2840.       else
  2841.         {
  2842.           do_jump (TREE_OPERAND (TREE_OPERAND (exp, 1), 0), 0, op0);
  2843.           thenexp = TREE_OPERAND (TREE_OPERAND (exp, 1), 2);
  2844.         }
  2845.  
  2846.       if (thenv == 0)
  2847.         thenv = expand_expr (thenexp, 0, VOIDmode, 0);
  2848.  
  2849.       /* THENV is now Z, the value to operate on, as an rtx.
  2850.          We have already tested that Y isn't zero, so do the operation.  */
  2851.  
  2852.       if (this_optab == rotl_optab || this_optab == rotr_optab)
  2853.         temp = expand_binop (mode, this_optab, target, thenv, target,
  2854.                  -1, OPTAB_LIB);
  2855.       else if (this_optab == lshl_optab || this_optab == lshr_optab)
  2856.         temp = expand_binop (mode, this_optab, target, thenv, target,
  2857.                  1, OPTAB_LIB_WIDEN);
  2858.       else
  2859.         temp = expand_binop (mode, this_optab, target, thenv, target,
  2860.                  0, OPTAB_LIB_WIDEN);
  2861.       if (target != temp)
  2862.         emit_move_insn (target, temp);
  2863.  
  2864.       do_pending_stack_adjust ();
  2865.       emit_label (op0);
  2866.       return target;
  2867.     }
  2868.     }
  2869.   subtarget = validate_subtarget (subtarget, TREE_OPERAND (exp, 1));
  2870.   op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
  2871.   op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  2872.  binop2:
  2873.   temp = expand_binop (mode, this_optab, op0, op1, target,
  2874.                TREE_UNSIGNED (TREE_TYPE (exp)), OPTAB_LIB_WIDEN);
  2875.  binop1:
  2876.   if (temp == 0)
  2877.     abort ();
  2878.   return temp;
  2879. }
  2880.  
  2881. /* Expand an expression EXP that calls a built-in function,
  2882.    with result going to TARGET if that's convenient
  2883.    (and in mode MODE if that's convenient).
  2884.    SUBTARGET may be used as the target for computing one of EXP's operands.  */
  2885.  
  2886. static rtx
  2887. expand_builtin (exp, target, subtarget, mode)
  2888.      tree exp;
  2889.      rtx target;
  2890.      rtx subtarget;
  2891.      enum machine_mode mode;
  2892. {
  2893.   tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0);
  2894.   tree arglist = TREE_OPERAND (exp, 1);
  2895.   rtx op0;
  2896.   rtx temp;
  2897.  
  2898.   switch (DECL_FUNCTION_CODE (fndecl))
  2899.     {
  2900.     case BUILT_IN_ABS:
  2901.     case BUILT_IN_LABS:
  2902.     case BUILT_IN_FABS:
  2903.       /* build_function_call changes these into ABS_EXPR.  */
  2904.       abort ();
  2905.  
  2906.     case BUILT_IN_ALLOCA:
  2907.       if (arglist == 0)
  2908.     return const0_rtx;
  2909.       frame_pointer_needed = 1;
  2910.       /* Compute the argument.  */
  2911.       op0 = expand_expr (TREE_VALUE (arglist), 0, VOIDmode, 0);
  2912.       if (! CONSTANT_P (op0))
  2913.     {
  2914.       op0 = force_reg (GET_MODE (op0), op0);
  2915.       if (GET_MODE (op0) != Pmode)
  2916.         op0 = convert_to_mode (Pmode, op0);
  2917.     }
  2918.       /* Push that much space (rounding it up).  */
  2919.       do_pending_stack_adjust ();
  2920. #ifdef STACK_GROWS_DOWNWARD
  2921.       anti_adjust_stack (round_push (op0));
  2922. #endif
  2923.       /* Return a copy of current stack ptr, in TARGET if possible.  */
  2924.       if (target)
  2925.     emit_move_insn (target, stack_pointer_rtx);
  2926.       else
  2927.     target = copy_to_reg (stack_pointer_rtx);
  2928. #ifdef STACK_POINTER_OFFSET
  2929.       /* If the contents of the stack pointer reg are offset from the
  2930.      actual top-of-stack address, add the offset here.  */
  2931.       if (GET_CODE (target) == REG)
  2932.     emit_insn (gen_add2_insn (target, gen_rtx (CONST_INT, VOIDmode,
  2933.                            STACK_POINTER_OFFSET)));
  2934.       else
  2935.     {
  2936.       rtx temp =
  2937.         expand_binop (GET_MODE (target), add_optab, target,
  2938.               gen_rtx (CONST_INT, VOIDmode, STACK_POINTER_OFFSET),
  2939.               target,
  2940.               1, OPTAB_DIRECT);
  2941.       if (temp == 0) abort ();
  2942.       if (temp != target)
  2943.         emit_move_insn (target, temp);
  2944.     }
  2945. #endif
  2946. #ifndef STACK_GROWS_DOWNWARD
  2947.       anti_adjust_stack (round_push (op0));
  2948. #endif
  2949.       return target;
  2950.  
  2951.     case BUILT_IN_FFS:
  2952.       if (arglist == 0)
  2953.     return const0_rtx;
  2954.  
  2955.       /* Compute the argument.  */
  2956.       op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0);
  2957.       /* Compute ffs, into TARGET if possible.
  2958.      Set TARGET to wherever the result comes back.  */
  2959.       target = expand_unop (mode, ffs_optab, op0, target, 1);
  2960.       if (target == 0)
  2961.     abort ();
  2962.       return target;
  2963.  
  2964.     default:
  2965.       abort ();
  2966.     }
  2967. }
  2968.  
  2969. /* Expand code for a post- or pre- increment or decrement
  2970.    and return the RTX for the result.
  2971.    POST is 1 for postinc/decrements and 0 for preinc/decrements.  */
  2972.  
  2973. static rtx
  2974. expand_increment (exp, post)
  2975.      register tree exp;
  2976.      int post;
  2977. {
  2978.   register rtx op0, op1;
  2979.   register rtx temp;
  2980.   register tree incremented = TREE_OPERAND (exp, 0);
  2981.   optab this_optab = add_optab;
  2982.   int icode;
  2983.   enum machine_mode mode = TYPE_MODE (TREE_TYPE (exp));
  2984.   int op0_is_copy = 0;
  2985.  
  2986.   /* Stabilize any component ref that might need to be
  2987.      evaluated more than once below.  */
  2988.   if (TREE_CODE (incremented) == COMPONENT_REF
  2989.       && (TREE_CODE (TREE_OPERAND (incremented, 0)) != INDIRECT_REF
  2990.       || DECL_MODE (TREE_OPERAND (exp, 1)) == BImode))
  2991.     incremented = stabilize_reference (incremented);
  2992.  
  2993.   /* Compute the operands as RTX.
  2994.      Note whether OP0 is the actual lvalue or a copy of it:
  2995.      I believe it is a copy iff it is a register and insns were
  2996.      generated in computing it.  */
  2997.   temp = get_last_insn ();
  2998.   op0 = expand_expr (incremented, 0, VOIDmode, 0);
  2999.   if (temp != get_last_insn ())
  3000.     op0_is_copy = (GET_CODE (op0) == REG || GET_CODE (op0) == SUBREG);
  3001.   op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  3002.  
  3003.   /* Decide whether incrementing or decrementing.  */
  3004.   if (TREE_CODE (exp) == POSTDECREMENT_EXPR
  3005.       || TREE_CODE (exp) == PREDECREMENT_EXPR)
  3006.     this_optab = sub_optab;
  3007.  
  3008.   /* If OP0 is not the actual lvalue, but rather a copy in a register,
  3009.      then we cannot just increment OP0.  We must
  3010.      therefore contrive to increment the original value.
  3011.      Then we can return OP0 since it is a copy of the old value.  */
  3012.   if (op0_is_copy)
  3013.     {
  3014.       /* This is the easiest way to increment the value wherever it is.
  3015.      Problems with multiple evaluation of INCREMENTED
  3016.      are prevented because either (1) it is a component_ref,
  3017.      in which case it was stabilized above, or (2) it is an array_ref
  3018.      with constant index in an array in a register, which is
  3019.      safe to reevaluate.  */
  3020.       tree newexp = build ((this_optab == add_optab
  3021.                 ? PLUS_EXPR : MINUS_EXPR),
  3022.                TREE_TYPE (exp),
  3023.                incremented,
  3024.                TREE_OPERAND (exp, 1));
  3025.       temp = expand_assignment (incremented, newexp, ! post, 0);
  3026.       return post ? op0 : temp;
  3027.     }
  3028.  
  3029.   /* Convert decrement by a constant into a negative increment.  */
  3030.   if (this_optab == sub_optab
  3031.       && GET_CODE (op1) == CONST_INT)
  3032.     {
  3033.       op1 = gen_rtx (CONST_INT, VOIDmode, - INTVAL (op1));
  3034.       this_optab = add_optab;
  3035.     }
  3036.  
  3037.   if (post)
  3038.     {
  3039.       /* We have a true reference to the value in OP0.
  3040.      If there is an insn to add or subtract in this mode, queue it.  */
  3041.  
  3042.       /* I'm not sure this is still necessary.  */
  3043.       op0 = stabilize (op0);
  3044.  
  3045.       icode = (int) this_optab->handlers[(int) mode].insn_code;
  3046.       if (icode != (int) CODE_FOR_nothing
  3047.       /* Make sure that OP0 is valid for operands 0 and 1
  3048.          of the insn we want to queue.  */
  3049.       && (*insn_operand_predicate[icode][0]) (op0, mode)
  3050.       && (*insn_operand_predicate[icode][1]) (op0, mode))
  3051.     {
  3052.       if (! (*insn_operand_predicate[icode][2]) (op1, mode))
  3053.         op1 = force_reg (mode, op1);
  3054.  
  3055.       return enqueue_insn (op0, GEN_FCN (icode) (op0, op0, op1));
  3056.     }
  3057.     }
  3058.  
  3059.   /* Preincrement, or we can't increment with one simple insn.  */
  3060.   if (post)
  3061.     /* Save a copy of the value before inc or dec, to return it later.  */
  3062.     temp = copy_to_reg (op0);
  3063.   else
  3064.     /* Arrange to return the incremented value.  */
  3065.     temp = op0;
  3066.  
  3067.   /* Increment however we can.  */
  3068.   op1 = expand_binop (mode, this_optab, op0, op1, op0,
  3069.               0, OPTAB_LIB_WIDEN);
  3070.   /* Make sure the value is stored into OP0.  */
  3071.   if (op1 != op0)
  3072.     emit_move_insn (op0, op1);
  3073.  
  3074.   return temp;
  3075. }
  3076.  
  3077. /* Expand all function calls contained within EXP, innermost ones first.
  3078.    But don't look within expressions that have sequence points.
  3079.    For each CALL_EXPR, record the rtx for its value
  3080.    in the CALL_EXPR_RTL field.
  3081.  
  3082.    Calls that return large structures for which a structure return
  3083.    stack slot is needed are not preexpanded.  Preexpanding them loses
  3084.    because if more than one were preexpanded they would try to use the
  3085.    same stack slot.  */
  3086.  
  3087. static void
  3088. preexpand_calls (exp)
  3089.      tree exp;
  3090. {
  3091.   register int nops, i;
  3092.  
  3093.   if (! do_preexpand_calls)
  3094.     return;
  3095.  
  3096.   /* Only expressions and references can contain calls.  */
  3097.  
  3098.   if (tree_code_type[(int) TREE_CODE (exp)][0] != 'e'
  3099.       && tree_code_type[(int) TREE_CODE (exp)][0] != 'r')
  3100.     return;
  3101.  
  3102.   switch (TREE_CODE (exp))
  3103.     {
  3104.     case CALL_EXPR:
  3105.       /* Do nothing to built-in functions.  */
  3106.       if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
  3107.       && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) == FUNCTION_DECL
  3108.       && (DECL_FUNCTION_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0))
  3109.           != NOT_BUILT_IN))
  3110.     return;
  3111.       if (CALL_EXPR_RTL (exp) == 0
  3112.       && TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
  3113.     CALL_EXPR_RTL (exp) = expand_call (exp, 0, 0);
  3114.       return;
  3115.  
  3116.     case COMPOUND_EXPR:
  3117.     case COND_EXPR:
  3118.     case TRUTH_ANDIF_EXPR:
  3119.     case TRUTH_ORIF_EXPR:
  3120.       /* If we find one of these, then we can be sure
  3121.      the adjust will be done for it (since it makes jumps).
  3122.      Do it now, so that if this is inside an argument
  3123.      of a function, we don't get the stack adjustment
  3124.      after some other args have already been pushed.  */
  3125.       do_pending_stack_adjust ();
  3126.       return;
  3127.  
  3128.     case RTL_EXPR:
  3129.       return;
  3130.  
  3131.     case SAVE_EXPR:
  3132.       if (SAVE_EXPR_RTL (exp) != 0)
  3133.     return;
  3134.     }
  3135.  
  3136.   nops = tree_code_length[(int) TREE_CODE (exp)];
  3137.   for (i = 0; i < nops; i++)
  3138.     if (TREE_OPERAND (exp, i) != 0)
  3139.       {
  3140.     register int type = *tree_code_type[(int) TREE_CODE (TREE_OPERAND (exp, i))];
  3141.     if (type == 'e' || type == 'r')
  3142.       preexpand_calls (TREE_OPERAND (exp, i));
  3143.       }
  3144. }
  3145.  
  3146. /* Force FUNEXP into a form suitable for the address of a CALL,
  3147.    and return that as an rtx.  Also load the static chain register
  3148.    from either FUNEXP or CONTEXT.  */
  3149.  
  3150. static rtx
  3151. prepare_call_address (funexp, context)
  3152.      rtx funexp;
  3153.      rtx context;
  3154. {
  3155.   funexp = protect_from_queue (funexp, 0);
  3156.   if (context != 0)
  3157.     context = protect_from_queue (context, 0);
  3158.  
  3159.   /* Function variable in language with nested functions.  */
  3160.   if (GET_MODE (funexp) == EPmode)
  3161.     {
  3162.       emit_move_insn (static_chain_rtx, gen_highpart (Pmode, funexp));
  3163.       funexp = memory_address (FUNCTION_MODE, gen_lowpart (Pmode, funexp));
  3164.       emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
  3165.     }
  3166.   else
  3167.     {
  3168.       if (context != 0)
  3169.     /* Unless function variable in C, or top level function constant */
  3170.     emit_move_insn (static_chain_rtx, lookup_static_chain (context));
  3171.  
  3172.       /* Make a valid memory address and copy constants thru pseudo-regs,
  3173.      but not for a constant address if -fno-function-cse.  */
  3174.       if (GET_CODE (funexp) != SYMBOL_REF)
  3175.     funexp = memory_address (FUNCTION_MODE, funexp);
  3176.       else
  3177.     {
  3178. #ifndef NO_FUNCTION_CSE
  3179.       if (optimize && ! flag_no_function_cse)
  3180.         funexp = force_reg (Pmode, funexp);
  3181. #endif
  3182.     }
  3183.  
  3184.       if (context != 0)
  3185.     emit_insn (gen_rtx (USE, VOIDmode, static_chain_rtx));
  3186.     }
  3187.   return funexp;
  3188. }
  3189.  
  3190. /* Generate instructions to call function FUNEXP,
  3191.    and optionally pop the results.
  3192.    The CALL_INSN is the first insn generated.
  3193.  
  3194.    FUNTYPE is the data type of the function, or, for a library call,
  3195.    the identifier for the name of the call.  This is given to the
  3196.    macro RETURN_POPS_ARGS to determine whether this function pops its own args.
  3197.  
  3198.    STACK_SIZE is the number of bytes of arguments on the stack,
  3199.    rounded up to STACK_BOUNDARY; zero if the size is variable.
  3200.    This is both to put into the call insn and
  3201.    to generate explicit popping code if necessary.
  3202.  
  3203.    NEXT_ARG_REG is the rtx that results from executing
  3204.      FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1)
  3205.    just after all the args have had their registers assigned.
  3206.    This could be whatever you like, but normally it is the first
  3207.    arg-register beyond those used for args in this call,
  3208.    or 0 if all the arg-registers are used in this call.
  3209.    It is passed on to `gen_call' so you can put this info in the call insn.
  3210.  
  3211.    VALREG is a hard register in which a value is returned,
  3212.    or 0 if the call does not return a value.
  3213.  
  3214.    OLD_ARGS_SIZE is the value that `current_args_size' had before
  3215.    the args to this call were processed.
  3216.    We restore `current_args_size' to that value.  */
  3217.  
  3218. static void
  3219. emit_call_1 (funexp, funtype, stack_size, next_arg_reg, valreg, old_args_size)
  3220.      rtx funexp;
  3221.      tree funtype;
  3222.      int stack_size;
  3223.      rtx next_arg_reg;
  3224.      rtx valreg;
  3225.      int old_args_size;
  3226. {
  3227.   rtx stack_size_rtx = gen_rtx (CONST_INT, VOIDmode, stack_size);
  3228.  
  3229.   if (valreg)
  3230.     emit_call_insn (gen_call_value (valreg,
  3231.                     gen_rtx (MEM, FUNCTION_MODE, funexp),
  3232.                     stack_size_rtx, next_arg_reg));
  3233.   else
  3234.     emit_call_insn (gen_call (gen_rtx (MEM, FUNCTION_MODE, funexp),
  3235.                   stack_size_rtx, next_arg_reg));
  3236.  
  3237.   current_args_size = old_args_size;
  3238.  
  3239.   /* If returning from the subroutine does not automatically pop the args,
  3240.      we need an instruction to pop them sooner or later.
  3241.      Perhaps do it now; perhaps just record how much space to pop later.  */
  3242.  
  3243.   if (! RETURN_POPS_ARGS (TREE_TYPE (funtype))
  3244.       && stack_size != 0)
  3245.     {
  3246.       if (flag_defer_pop && current_args_size == 0)
  3247.     pending_stack_adjust += stack_size;
  3248.       else
  3249.     adjust_stack (stack_size_rtx);
  3250.     }
  3251. }
  3252.  
  3253. /* At the start of a function, record that we have no previously-pushed
  3254.    arguments waiting to be popped.  */
  3255.  
  3256. void
  3257. init_pending_stack_adjust ()
  3258. {
  3259.   pending_stack_adjust = 0;
  3260. }
  3261.  
  3262. /* When exiting from function, if safe, clear out any pending stack adjust
  3263.    so the adjustment won't get done.  */
  3264.  
  3265. void
  3266. clear_pending_stack_adjust ()
  3267. {
  3268. #ifdef EXIT_IGNORE_STACK
  3269.   if (!flag_omit_frame_pointer && EXIT_IGNORE_STACK
  3270.       && ! TREE_INLINE (current_function_decl))
  3271.     pending_stack_adjust = 0;
  3272. #endif
  3273. }
  3274.  
  3275. /* At start of function, initialize.  */
  3276. void
  3277. clear_current_args_size ()
  3278. {
  3279.   current_args_size = 0;
  3280. }
  3281.  
  3282. /* Pop any previously-pushed arguments that have not been popped yet.  */
  3283.  
  3284. void
  3285. do_pending_stack_adjust ()
  3286. {
  3287.   if (current_args_size == 0)
  3288.     {
  3289.       if (pending_stack_adjust != 0)
  3290.     adjust_stack (gen_rtx (CONST_INT, VOIDmode, pending_stack_adjust));
  3291.       pending_stack_adjust = 0;
  3292.     }
  3293. }
  3294.  
  3295. /* Generate all the code for a function call
  3296.    and return an rtx for its value.
  3297.    Store the value in TARGET (specified as an rtx) if convenient.
  3298.    If the value is stored in TARGET then TARGET is returned.
  3299.    If IGNORE is nonzero, then we ignore the value of the function call.  */
  3300.  
  3301. static rtx
  3302. expand_call (exp, target, ignore)
  3303.      tree exp;
  3304.      rtx target;
  3305.      int ignore;
  3306. {
  3307.   tree actparms = TREE_OPERAND (exp, 1);
  3308.   tree funtype;
  3309.   rtx funexp;
  3310.   register tree p = TREE_OPERAND (exp, 0);
  3311.   struct args_size args_size;
  3312.   register int i;
  3313.   register tree *argvec;
  3314.   rtx *regvec;
  3315.   rtx *valvec;
  3316.   int *partial;
  3317.   struct args_size *arg_offset;
  3318.   struct args_size *arg_size;
  3319.   int num_actuals;
  3320.   rtx structure_value_addr = 0;
  3321.   tree fndecl = 0;
  3322.   int may_be_alloca;
  3323.   int inc;
  3324.   int is_setjmp;
  3325.   int is_integrable = 0;
  3326.   rtx argblock = 0;
  3327.   CUMULATIVE_ARGS args_so_far;
  3328.   int reg_parm_seen = 0;
  3329.   rtx valreg;
  3330.   rtx old_stack_level;
  3331.   int old_pending_adj;
  3332.   int old_current_args_size = current_args_size;
  3333.  
  3334.   /* Number of named args.  Args after this are anonymous ones
  3335.      and they must all go on the stack.  */
  3336.   int n_named_args;
  3337.  
  3338.   args_size.constant = 0;
  3339.   args_size.var = 0;
  3340.  
  3341.   /* See if we can find a DECL-node for the actual function.
  3342.      As a result, decide whether this is a call to an integrable function.  */
  3343.  
  3344.   if (TREE_CODE (p) == ADDR_EXPR)
  3345.     {
  3346.       fndecl = TREE_OPERAND (p, 0);
  3347.       if (TREE_CODE (fndecl) != FUNCTION_DECL)
  3348.     fndecl = 0;
  3349.       else
  3350.     {
  3351.       extern tree current_function_decl;
  3352.  
  3353.       if (fndecl != current_function_decl
  3354.           && DECL_SAVED_INSNS (fndecl))
  3355.         is_integrable = 1;
  3356.       else
  3357.         {
  3358.           /* In case this function later becomes inlineable,
  3359.          record that there was already a non-inline call to it.  */
  3360.           TREE_ADDRESSABLE (fndecl) = 1;
  3361.           TREE_ADDRESSABLE (DECL_NAME (fndecl)) = 1;
  3362.         }
  3363.     }
  3364.     }
  3365.  
  3366.   /* Set up a place to return a structure.  */
  3367.  
  3368.   if (TYPE_MODE (TREE_TYPE (exp)) == BLKmode)
  3369.     {
  3370.       /* This call returns a big structure.  */
  3371.       if (target)
  3372.     structure_value_addr = XEXP (target, 0);
  3373.       else
  3374.     /* Make room on the stack to hold the value.  */
  3375.     structure_value_addr = get_structure_value_addr (expr_size (exp));
  3376.     }
  3377.  
  3378.   if (is_integrable)
  3379.     {
  3380.       extern int integration_time;
  3381.       extern rtx expand_inline_function ();
  3382.       rtx temp;
  3383.  
  3384.       temp = expand_inline_function (fndecl, actparms, target,
  3385.                      ignore, TREE_TYPE (exp),
  3386.                      structure_value_addr);
  3387.  
  3388.       if (temp != (rtx)-1)
  3389.     return temp;
  3390.     }
  3391.  
  3392. #if 0
  3393.   /* Unless it's a call to a specific function that isn't alloca,
  3394.      if it has one argument, we must assume it might be alloca.  */
  3395.  
  3396.   may_be_alloca =
  3397.     (!(fndecl != 0
  3398.        && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)),
  3399.           "alloca"))
  3400.      && actparms != 0
  3401.      && TREE_CHAIN (actparms) == 0);
  3402. #else
  3403.   /* We assume that alloca will always be called by name.  It
  3404.      makes no sense to pass it as a pointer-to-function to
  3405.      anything that does not understand its behavior.  */
  3406.   may_be_alloca =
  3407.     (fndecl && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "alloca"));
  3408. #endif
  3409.  
  3410.   /* See if this is a call to a function that can return more than once.  */
  3411.  
  3412.   is_setjmp
  3413.     = (fndecl != 0
  3414.        && (!strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "setjmp")
  3415.        || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "_setjmp")));
  3416.  
  3417.   if (may_be_alloca)
  3418.     {
  3419.       frame_pointer_needed = 1;
  3420.       may_call_alloca = 1;
  3421.     }
  3422.  
  3423.   /* Don't let pending stack adjusts add up to too much.
  3424.      Also, do all pending adjustments now
  3425.      if there is any chance this might be a call to alloca.  */
  3426.  
  3427.   if (pending_stack_adjust >= 32
  3428.       || (pending_stack_adjust > 0 && may_be_alloca))
  3429.     do_pending_stack_adjust ();
  3430.  
  3431.   /* Operand 0 is a pointer-to-function; get the type of the function.  */
  3432.   funtype = TREE_TYPE (TREE_OPERAND (exp, 0));
  3433.   if (TREE_CODE (funtype) != POINTER_TYPE)
  3434.     abort ();
  3435.   funtype = TREE_TYPE (funtype);
  3436.  
  3437.   /* Pass the function the address in which to return a structure value.  */
  3438.   if (structure_value_addr && GET_CODE (struct_value_rtx) == MEM)
  3439.     actparms = tree_cons (error_mark_node,
  3440.               build (SAVE_EXPR,
  3441.                  type_for_size (BITS_PER_WORD, 0),
  3442.                  0, structure_value_addr),
  3443.               actparms);
  3444.  
  3445.   /* Count the arguments and set NUM_ACTUALS.  */
  3446.   for (p = actparms, i = 0; p; p = TREE_CHAIN (p)) i++;
  3447.   num_actuals = i;
  3448.  
  3449.   /* Compute number of named args.
  3450.      This may actually be 1 too large, but that happens
  3451.      only in the case when all args are named, so no trouble results.  */
  3452.   if (TYPE_ARG_TYPES (funtype) != 0)
  3453.     n_named_args = list_length (TYPE_ARG_TYPES (funtype));
  3454.   else
  3455.     /* If we know nothing, treat all args as named.  */
  3456.     n_named_args = num_actuals;
  3457.  
  3458.   /* Make a vector of the args, in the order we want to compute them,
  3459.      and a parallel vector of where we want to put them.
  3460.      regvec[I] is 0 to if should push argvec[I] or else a reg to put it in.
  3461.      valvec[i] is the arg value as an rtx.  */
  3462.   argvec = (tree *) alloca (num_actuals * sizeof (tree));
  3463.   regvec = (rtx *) alloca (num_actuals * sizeof (rtx));
  3464.   valvec = (rtx *) alloca (num_actuals * sizeof (rtx));
  3465.   partial = (int *) alloca (num_actuals * sizeof (int));
  3466.   arg_size = (struct args_size *) alloca (num_actuals * sizeof (struct args_size));
  3467.   arg_offset = (struct args_size *) alloca (num_actuals * sizeof (struct args_size));
  3468.  
  3469.   /* In this loop, we consider args in the order they are written.
  3470.      We fill up argvec from the front of from the back
  3471.      so that the first arg to be pushed ends up at the front.  */
  3472.  
  3473. #ifdef PUSH_ARGS_REVERSED
  3474.   i = num_actuals - 1, inc = -1;
  3475.   /* In this case, must reverse order of args
  3476.      so that we compute and push the last arg first.  */
  3477. #else
  3478.   i = 0, inc = 1;
  3479. #endif
  3480.  
  3481.   INIT_CUMULATIVE_ARGS (args_so_far, funtype);
  3482.  
  3483.   for (p = actparms; p; p = TREE_CHAIN (p), i += inc)
  3484.     {
  3485.       tree type = TREE_TYPE (TREE_VALUE (p));
  3486.       argvec[i] = p;
  3487.       regvec[i] = 0;
  3488.       valvec[i] = 0;
  3489.       partial[i] = 0;
  3490.       arg_size[i].constant = 0;
  3491.       arg_size[i].var = 0;
  3492.       arg_offset[i] = args_size;
  3493.  
  3494. #ifdef STACK_POINTER_OFFSET
  3495.       /* ARG_OFFSET is used to index ARGS_ADDR, which is the stack ptr reg,
  3496.      so if there is a gap between that reg and the actual t.o.s. addr,
  3497.      we must include it in this offset.  */
  3498.       arg_offset[i].constant += STACK_POINTER_OFFSET;
  3499. #endif
  3500.  
  3501.       if (type == error_mark_node)
  3502.     continue;
  3503.  
  3504.       /* Decide where to pass this arg.  */
  3505.       /* regvec[i] is nonzero if all or part is passed in registers.
  3506.      partial[i] is nonzero if part but not all is passed in registers,
  3507.       and the exact value says how many words are passed in registers.  */
  3508.  
  3509.       if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
  3510.       && args_size.var == 0
  3511.       /* error_mark_node here is a flag for the fake argument
  3512.          for a structure value address.  */
  3513.       && TREE_PURPOSE (p) != error_mark_node)
  3514.     {
  3515.       regvec[i] = FUNCTION_ARG (args_so_far, TYPE_MODE (type), type,
  3516.                     i < n_named_args);
  3517. #ifdef FUNCTION_ARG_PARTIAL_NREGS
  3518.       partial[i] = FUNCTION_ARG_PARTIAL_NREGS (args_so_far,
  3519.                            TYPE_MODE (type), type,
  3520.                            i < n_named_args);
  3521. #endif
  3522.     }
  3523.  
  3524.       /* Once we see at least one parm that is being passed in a register,
  3525.      precompute that parm and all remaining parms (if they do arithmetic)
  3526.      before loading any of them into their specified registers.
  3527.      That way we don't lose if one of them involves
  3528.      a function call OR a library routine that needs the same regs.  */
  3529.       if (regvec[i] != 0)
  3530.     reg_parm_seen = 1;
  3531.  
  3532.       if (reg_parm_seen)
  3533.     {
  3534.       valvec[i] = expand_expr (TREE_VALUE (p), 0, VOIDmode, 0);
  3535.       if (GET_CODE (valvec[i]) != MEM
  3536.           && ! CONSTANT_P (valvec[i])
  3537.           && GET_CODE (valvec[i]) != CONST_DOUBLE)
  3538.         valvec[i] = force_reg (TYPE_MODE (type), valvec[i]);
  3539.       /* ANSI doesn't require a sequence point here,
  3540.          but PCC has one, so this will avoid some problems.  */
  3541.       emit_queue ();
  3542.     }
  3543.  
  3544.       /* Increment ARGS_SO_FAR, which has info about which arg-registers
  3545.      have been used, etc.  */
  3546.  
  3547.       FUNCTION_ARG_ADVANCE (args_so_far, TYPE_MODE (type), type,
  3548.                 i < n_named_args);
  3549.  
  3550.       /* Increment ARGS_SIZE, which is the size of all args so far.  */
  3551.  
  3552.       if (regvec[i] != 0 && partial[i] == 0)
  3553.     /* A register-arg doesn't count.  */
  3554.     ;
  3555.       else if (TYPE_MODE (type) != BLKmode)
  3556.     {
  3557.       register int size;
  3558.  
  3559.       size = GET_MODE_SIZE (TYPE_MODE (type));
  3560.       /* Compute how much space the push instruction will push.
  3561.          On many machines, pushing a byte will advance the stack
  3562.          pointer by a halfword.  */
  3563. #ifdef PUSH_ROUNDING
  3564.       size = PUSH_ROUNDING (size);
  3565. #endif
  3566.       /* Compute how much space the argument should get:
  3567.          maybe pad to a multiple of the alignment for arguments.  */
  3568.       if (none == FUNCTION_ARG_PADDING (TYPE_MODE (type), (rtx)0))
  3569.         arg_size[i].constant += size;
  3570.       else
  3571.         arg_size[i].constant
  3572.           = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
  3573.           / (PARM_BOUNDARY / BITS_PER_UNIT))
  3574.          * (PARM_BOUNDARY / BITS_PER_UNIT));
  3575.     }
  3576.       else
  3577.     {
  3578.       register tree size = size_in_bytes (type);
  3579.  
  3580.       /* A nonscalar.  Round its size up to a multiple
  3581.          of the allocation unit for arguments.  */
  3582.  
  3583.       /* Now maybe round up to multiple of PARM_BOUNDARY bits.  */
  3584.       if (none
  3585.           != FUNCTION_ARG_PADDING (TYPE_MODE (type),
  3586.                        expand_expr (size, 0, VOIDmode, 0)))
  3587.         size = convert_units (convert_units (size, BITS_PER_UNIT,
  3588.                          PARM_BOUNDARY),
  3589.                   PARM_BOUNDARY, BITS_PER_UNIT);
  3590.       ADD_PARM_SIZE (arg_size[i], size);
  3591.     }
  3592.       /* If a part of the arg was put into registers,
  3593.      don't include that part in the amount pushed.  */
  3594.       arg_size[i].constant
  3595.     -= ((partial[i] * UNITS_PER_WORD)
  3596.         / (PARM_BOUNDARY / BITS_PER_UNIT)
  3597.         * (PARM_BOUNDARY / BITS_PER_UNIT));
  3598.  
  3599.       args_size.constant += arg_size[i].constant;
  3600.  
  3601.       if (arg_size[i].var)
  3602.     {
  3603.       ADD_PARM_SIZE (args_size, arg_size[i].var);
  3604.     }
  3605.     }
  3606.  
  3607.   /* If we have no actual push instructions, or we need a variable
  3608.      amount of space, make space for all the args right now.
  3609.      In any case, round the needed size up to multiple of STACK_BOUNDARY.  */
  3610.  
  3611.   if (args_size.var != 0)
  3612.     {
  3613.       old_stack_level = copy_to_mode_reg (Pmode, stack_pointer_rtx);
  3614.       old_pending_adj = pending_stack_adjust;
  3615.       argblock = push_block (round_push (ARGS_SIZE_RTX (args_size)));
  3616.     }
  3617.   else if (args_size.constant != 0)
  3618.     {
  3619.       int needed = args_size.constant;
  3620.  
  3621. #ifdef STACK_BOUNDARY
  3622.       needed = (needed + STACK_BYTES - 1) / STACK_BYTES * STACK_BYTES;
  3623.       args_size.constant = needed;
  3624. #endif
  3625.  
  3626. #ifndef PUSH_ROUNDING
  3627.       /* Try to reuse some or all of the pending_stack_adjust
  3628.      to get this space.  Maybe we can avoid any pushing.  */
  3629.       if (needed > pending_stack_adjust)
  3630.     {
  3631.       needed -= pending_stack_adjust;
  3632.       pending_stack_adjust = 0;
  3633.     }
  3634.       else
  3635.     {
  3636.       pending_stack_adjust -= needed;
  3637.       needed = 0;
  3638.     }
  3639.       argblock = push_block (gen_rtx (CONST_INT, VOIDmode, needed));
  3640. #endif /* no PUSH_ROUNDING */
  3641.     }
  3642.  
  3643.   /* Get the function to call, in the form of RTL.  */
  3644.   if (fndecl)
  3645.     /* Get a SYMBOL_REF rtx for the function address.  */
  3646.     funexp = XEXP (DECL_RTL (fndecl), 0);
  3647.   else
  3648.     /* Generate an rtx (probably a pseudo-register) for the address.  */
  3649.     {
  3650.       funexp = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  3651.       emit_queue ();
  3652.     }
  3653.  
  3654.   /* Now actually compute the args, and push those that need pushing.  */
  3655.  
  3656.   for (i = 0; i < num_actuals; i++)
  3657.     {
  3658.       register tree p = argvec[i];
  3659.       register tree pval = TREE_VALUE (p);
  3660.       int used = 0;
  3661.  
  3662.       /* Push the next argument.  Note that it has already been converted
  3663.      if necessary to the type that the called function expects.  */
  3664.  
  3665.       if (TREE_CODE (pval) == ERROR_MARK)
  3666.     ;
  3667.       else if (regvec[i] != 0 && partial[i] == 0)
  3668.     {
  3669.       /* Being passed entirely in a register.  */
  3670.       if (valvec[i] != 0)
  3671.         {
  3672.           if (GET_MODE (valvec[i]) == BLKmode)
  3673.         move_block_to_reg (REGNO (regvec[i]), valvec[i],
  3674.                    (int_size_in_bytes (TREE_TYPE (pval))
  3675.                     / UNITS_PER_WORD));
  3676.           else
  3677.         emit_move_insn (regvec[i], valvec[i]);
  3678.         }
  3679.       else
  3680.         store_expr (pval, regvec[i], 0);
  3681.  
  3682.       /* Don't allow anything left on stack from computation
  3683.          of argument to alloca.  */
  3684.       if (may_be_alloca)
  3685.         do_pending_stack_adjust ();
  3686.     }
  3687.       else if (TYPE_MODE (TREE_TYPE (pval)) != BLKmode)
  3688.     {
  3689.       register int size;
  3690.       rtx tem;
  3691.  
  3692.       /* Argument is a scalar, not entirely passed in registers.
  3693.          (If part is passed in registers, partial[I] says how much
  3694.          and emit_push_insn will take care of putting it there.)
  3695.  
  3696.          Push it, and if its size is less than the
  3697.          amount of space allocated to it,
  3698.          also bump stack pointer by the additional space.
  3699.          Note that in C the default argument promotions
  3700.          will prevent such mismatches.  */
  3701.  
  3702.       used = size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (pval)));
  3703.       /* Compute how much space the push instruction will push.
  3704.          On many machines, pushing a byte will advance the stack
  3705.          pointer by a halfword.  */
  3706. #ifdef PUSH_ROUNDING
  3707.       size = PUSH_ROUNDING (size);
  3708. #endif
  3709.       /* Compute how much space the argument should get:
  3710.          round up to a multiple of the alignment for arguments.  */
  3711.       if (none != FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)), (rtx)0))
  3712.         used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
  3713.              / (PARM_BOUNDARY / BITS_PER_UNIT))
  3714.             * (PARM_BOUNDARY / BITS_PER_UNIT));
  3715.  
  3716.       tem = valvec[i];
  3717.       if (tem == 0)
  3718.         {
  3719.           tem = expand_expr (pval, 0, VOIDmode, 0);
  3720.           /* ANSI doesn't require a sequence point here,
  3721.          but PCC has one, so this will avoid some problems.  */
  3722.           emit_queue ();
  3723.         }
  3724.  
  3725.       /* Don't allow anything left on stack from computation
  3726.          of argument to alloca.  */
  3727.       if (may_be_alloca)
  3728.         do_pending_stack_adjust ();
  3729.  
  3730.       emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), 0, 0,
  3731.               partial[i], regvec[i], used - size,
  3732.               argblock, ARGS_SIZE_RTX (arg_offset[i]));
  3733.     }
  3734.       else
  3735.     {
  3736.       register rtx tem
  3737.         = valvec[i] ? valvec[i] : expand_expr (pval, 0, VOIDmode, 0);
  3738.       register int excess;
  3739.       rtx size_rtx;
  3740.  
  3741.       /* Pushing a nonscalar.
  3742.          If part is passed in registers, partial[I] says how much
  3743.          and emit_push_insn will take care of putting it there.  */
  3744.  
  3745.       /* Round its size up to a multiple
  3746.          of the allocation unit for arguments.  */
  3747.  
  3748.       if (arg_size[i].var != 0)
  3749.         {
  3750.           excess = 0;
  3751.           size_rtx = ARGS_SIZE_RTX (arg_size[i]);
  3752.         }
  3753.       else
  3754.         {
  3755.           register tree size = size_in_bytes (TREE_TYPE (pval));
  3756.           /* PUSH_ROUNDING has no effect on us, because
  3757.          emit_push_insn for BLKmode is careful to avoid it.  */
  3758.           excess = arg_size[i].constant - TREE_INT_CST_LOW (size);
  3759.           size_rtx = expand_expr (size, 0, VOIDmode, 0);
  3760.         }
  3761.  
  3762.       emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), size_rtx,
  3763.               TYPE_ALIGN (TREE_TYPE (pval)) / BITS_PER_UNIT,
  3764.               partial[i], regvec[i], excess, argblock,
  3765.               ARGS_SIZE_RTX (arg_offset[i]));
  3766.     }
  3767.  
  3768.       /* Account for the stack space thus used.  */
  3769.  
  3770.  
  3771.       current_args_size += arg_size[i].constant;
  3772.       if (arg_size[i].var)
  3773.     current_args_size += 1;
  3774.     }
  3775.  
  3776.   /* Perform postincrements before actually calling the function.  */
  3777.   emit_queue ();
  3778.  
  3779.   /* Pass the function the address in which to return a structure value.  */
  3780.   if (structure_value_addr && GET_CODE (struct_value_rtx) != MEM)
  3781.     emit_move_insn (struct_value_rtx, structure_value_addr);
  3782.  
  3783.   /* All arguments and registers used for the call must be set up by now!  */
  3784.  
  3785.   /* ??? Other languages need a nontrivial second argument (static chain).  */
  3786.   funexp = prepare_call_address (funexp, 0);
  3787.  
  3788.   /* Mark all register-parms as living through the call.
  3789.      ??? This is not quite correct, since it doesn't indicate
  3790.      that they are in use immediately before the call insn.
  3791.      Currently that doesn't matter since explicitly-used regs
  3792.      won't be used for reloading.  But if the reloader becomes smarter,
  3793.      this will have to change somehow.  */
  3794.   for (i = 0; i < num_actuals; i++)
  3795.     if (regvec[i] != 0)
  3796.       {
  3797.     if (partial[i] > 0)
  3798.       use_regs (REGNO (regvec[i]), partial[i]);
  3799.     else if (GET_MODE (regvec[i]) == BLKmode)
  3800.       use_regs (REGNO (regvec[i]),
  3801.             (int_size_in_bytes (TREE_TYPE (TREE_VALUE (argvec[i])))
  3802.              / UNITS_PER_WORD));
  3803.     else
  3804.       emit_insn (gen_rtx (USE, VOIDmode, regvec[i]));
  3805.       }
  3806.  
  3807.   if (structure_value_addr)
  3808.     emit_insn (gen_rtx (USE, VOIDmode, struct_value_rtx));
  3809.  
  3810.   /* Figure out the register where the value, if any, will come back.  */
  3811.   valreg = 0;
  3812.   if (TYPE_MODE (TREE_TYPE (exp)) != VOIDmode
  3813.       && TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
  3814.     valreg = hard_function_value (TREE_TYPE (exp), fndecl);
  3815.  
  3816.   /* Generate the actual call instruction.  */
  3817.   emit_call_1 (funexp, funtype, args_size.constant,
  3818.            FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
  3819.            valreg, old_current_args_size);
  3820.  
  3821. /* ???  Nothing has been done here to record control flow
  3822.    when contained functions can do nonlocal gotos.  */
  3823.  
  3824.   /* For calls to `setjmp', etc., inform flow.c it should complain
  3825.      if nonvolatile values are live.  */
  3826.  
  3827.   if (is_setjmp)
  3828.     emit_note (IDENTIFIER_POINTER (DECL_NAME (fndecl)), NOTE_INSN_SETJMP);
  3829.  
  3830.   /* If size of args is variable, restore saved stack-pointer value.  */
  3831.  
  3832.   if (args_size.var != 0)
  3833.     {
  3834.       emit_move_insn (stack_pointer_rtx, old_stack_level);
  3835.       pending_stack_adjust = old_pending_adj;
  3836.     }
  3837.  
  3838.   /* If value type not void, return an rtx for the value.  */
  3839.  
  3840.   if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode
  3841.       || ignore)
  3842.     return 0;
  3843.  
  3844.   if (structure_value_addr)
  3845.     {
  3846.       if (target)
  3847.     return target;
  3848.       return gen_rtx (MEM, BLKmode,
  3849.               memory_address (BLKmode, structure_value_addr));
  3850.     }
  3851.  
  3852.  if (target && GET_MODE (target) == TYPE_MODE (TREE_TYPE (exp)))
  3853.     {
  3854.       if (!rtx_equal_p (target, valreg))
  3855.     emit_move_insn (target, valreg);
  3856.       else
  3857.     /* This tells expand_inline_function to copy valreg to its target.  */
  3858.     emit_insn (gen_rtx (USE, VOIDmode, valreg));
  3859.       return target;
  3860.     }
  3861.   return copy_to_reg (valreg);
  3862. }
  3863.  
  3864. /* Expand conditional expressions.  */
  3865.  
  3866. /* Generate code to evaluate EXP and jump to LABEL if the value is zero.
  3867.    LABEL is an rtx of code CODE_LABEL, in this function and all the
  3868.    functions here.  */
  3869.  
  3870. void
  3871. jumpifnot (exp, label)
  3872.      tree exp;
  3873.      rtx label;
  3874. {
  3875.   do_jump (exp, label, 0);
  3876. }
  3877.  
  3878. /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero.  */
  3879.  
  3880. void
  3881. jumpif (exp, label)
  3882.      tree exp;
  3883.      rtx label;
  3884. {
  3885.   do_jump (exp, 0, label);
  3886. }
  3887.  
  3888. /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if
  3889.    the result is zero, or IF_TRUE_LABEL if the result is one.
  3890.    Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero,
  3891.    meaning fall through in that case.
  3892.  
  3893.    This function is responsible for optimizing cases such as
  3894.    &&, || and comparison operators in EXP.  */
  3895.  
  3896. void
  3897. do_jump (exp, if_false_label, if_true_label)
  3898.      tree exp;
  3899.      rtx if_false_label, if_true_label;
  3900. {
  3901.   register enum tree_code code = TREE_CODE (exp);
  3902.   /* Some cases need to create a label to jump to
  3903.      in order to properly fall through.
  3904.      These cases set DROP_THROUGH_LABEL nonzero.  */
  3905.   rtx drop_through_label = 0;
  3906.   rtx temp;
  3907.   rtx comparison = 0;
  3908.  
  3909.   emit_queue ();
  3910.  
  3911.   switch (code)
  3912.     {
  3913.     case ERROR_MARK:
  3914.       break;
  3915.  
  3916.     case INTEGER_CST:
  3917.       temp = integer_zerop (exp) ? if_false_label : if_true_label;
  3918.       if (temp)
  3919.     emit_jump (temp);
  3920.       break;
  3921.  
  3922.     case ADDR_EXPR:
  3923.       /* The address of something can never be zero.  */
  3924.       if (if_true_label)
  3925.     emit_jump (if_true_label);
  3926.       break;
  3927.  
  3928.     case NOP_EXPR:
  3929.       do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label);
  3930.       break;
  3931.  
  3932.     case TRUTH_NOT_EXPR:
  3933.       do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label);
  3934.       break;
  3935.  
  3936.     case TRUTH_ANDIF_EXPR:
  3937.       if (if_false_label == 0)
  3938.     if_false_label = drop_through_label = gen_label_rtx ();
  3939.       do_jump (TREE_OPERAND (exp, 0), if_false_label, 0);
  3940.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  3941.       break;
  3942.  
  3943.     case TRUTH_ORIF_EXPR:
  3944.       if (if_true_label == 0)
  3945.     if_true_label = drop_through_label = gen_label_rtx ();
  3946.       do_jump (TREE_OPERAND (exp, 0), 0, if_true_label);
  3947.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  3948.       break;
  3949.  
  3950.     case COMPOUND_EXPR:
  3951.       expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0);
  3952.       emit_queue ();
  3953.       do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label);
  3954.       break;
  3955.  
  3956.     case COND_EXPR:
  3957.       {
  3958.     register rtx label1 = gen_label_rtx ();
  3959.     drop_through_label = gen_label_rtx ();
  3960.     do_jump (TREE_OPERAND (exp, 0), label1, 0);
  3961.     /* Now the THEN-expression.  */
  3962.     do_jump (TREE_OPERAND (exp, 1),
  3963.          if_false_label ? if_false_label : drop_through_label,
  3964.          if_true_label ? if_true_label : drop_through_label);
  3965.     emit_label (label1);
  3966.     /* Now the ELSE-expression.  */
  3967.     do_jump (TREE_OPERAND (exp, 2),
  3968.          if_false_label ? if_false_label : drop_through_label,
  3969.          if_true_label ? if_true_label : drop_through_label);
  3970.       }
  3971.       break;
  3972.  
  3973.     case EQ_EXPR:
  3974.       comparison = compare (exp, EQ, EQ, EQ, EQ);
  3975.       break;
  3976.  
  3977.     case NE_EXPR:
  3978.       comparison = compare (exp, NE, NE, NE, NE);
  3979.       break;
  3980.  
  3981.     case LT_EXPR:
  3982.       comparison = compare (exp, LT, LTU, GT, GTU);
  3983.       break;
  3984.  
  3985.     case LE_EXPR:
  3986.       comparison = compare (exp, LE, LEU, GE, GEU);
  3987.       break;
  3988.  
  3989.     case GT_EXPR:
  3990.       comparison = compare (exp, GT, GTU, LT, LTU);
  3991.       break;
  3992.  
  3993.     case GE_EXPR:
  3994.       comparison = compare (exp, GE, GEU, LE, LEU);
  3995.       break;
  3996.  
  3997.     default:
  3998.       temp = expand_expr (exp, 0, VOIDmode, 0);
  3999.       /* Copy to register to avoid generating bad insns by cse
  4000.      from (set (mem ...) (arithop))  (set (cc0) (mem ...)).  */
  4001.       if (!cse_not_expected && GET_CODE (temp) == MEM)
  4002.     temp = copy_to_reg (temp);
  4003.       do_pending_stack_adjust ();
  4004.       {
  4005.     rtx zero;
  4006.     if (GET_MODE (temp) == SFmode)
  4007.       zero = fconst0_rtx;
  4008.     else if (GET_MODE (temp) == DFmode)
  4009.       zero = dconst0_rtx;
  4010.     else
  4011.       zero = const0_rtx;
  4012.  
  4013.     if (GET_CODE (temp) == CONST_INT)
  4014.       comparison = compare_constants (NE, 0,
  4015.                       INTVAL (temp), 0, BITS_PER_WORD);
  4016.     else if (GET_MODE (temp) != VOIDmode)
  4017.       comparison = compare1 (temp, zero, NE, NE, 0, GET_MODE (temp));
  4018.     else
  4019.       abort ();
  4020.       }
  4021.     }
  4022.  
  4023.   /* Do any postincrements in the expression that was tested.  */
  4024.   emit_queue ();
  4025.  
  4026.   /* If COMPARISON is nonzero here, it is an rtx that can be substituted
  4027.      straight into a conditional jump instruction as the jump condition.
  4028.      Otherwise, all the work has been done already.  */
  4029.  
  4030.   if (comparison == const1_rtx)
  4031.     {
  4032.       if (if_true_label)
  4033.     emit_jump (if_true_label);
  4034.     }
  4035.   else if (comparison == const0_rtx)
  4036.     {
  4037.       if (if_false_label)
  4038.     emit_jump (if_false_label);
  4039.     }
  4040.   else if (comparison)
  4041.     {
  4042.       if (if_true_label)
  4043.     {
  4044.       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
  4045.                    gen_rtx (IF_THEN_ELSE, VOIDmode, comparison,
  4046.                         gen_rtx (LABEL_REF, VOIDmode,
  4047.                              if_true_label),
  4048.                         pc_rtx)));
  4049.       if (if_false_label)
  4050.         emit_jump (if_false_label);
  4051.     }
  4052.       else if (if_false_label)
  4053.     {
  4054.       emit_jump_insn (gen_rtx (SET, VOIDmode, pc_rtx,
  4055.                    gen_rtx (IF_THEN_ELSE, VOIDmode, comparison,
  4056.                         pc_rtx,
  4057.                         gen_rtx (LABEL_REF, VOIDmode,
  4058.                              if_false_label))));
  4059.     }
  4060.     }
  4061.  
  4062.   if (drop_through_label)
  4063.     emit_label (drop_through_label);
  4064. }
  4065.  
  4066. /* Compare two integer constant rtx's, OP0 and OP1.
  4067.    The comparison operation is OPERATION.
  4068.    Return an rtx representing the value 1 or 0.
  4069.    WIDTH is the width in bits that is significant.  */
  4070.  
  4071. static rtx
  4072. compare_constants (operation, unsignedp, op0, op1, width)
  4073.      enum rtx_code operation;
  4074.      int unsignedp;
  4075.      int op0, op1;
  4076.      int width;
  4077. {
  4078.   int val;
  4079.  
  4080.   /* Sign-extend or zero-extend the operands to a full word
  4081.      from an initial width of WIDTH bits.  */
  4082.   if (width < HOST_BITS_PER_INT)
  4083.     {
  4084.       op0 &= (1 << width) - 1;
  4085.       op1 &= (1 << width) - 1;
  4086.  
  4087.       if (! unsignedp)
  4088.     {
  4089.       if (op0 & (1 << (width - 1)))
  4090.         op0 |= ((-1) << width);
  4091.       if (op1 & (1 << (width - 1)))
  4092.         op1 |= ((-1) << width);
  4093.     }
  4094.     }
  4095.  
  4096.   switch (operation)
  4097.     {
  4098.     case EQ:
  4099.       val = op0 == op1;
  4100.       break;
  4101.  
  4102.     case NE:
  4103.       val = op0 != op1;
  4104.       break;
  4105.  
  4106.     case GT:
  4107.     case GTU:
  4108.       val = op0 > op1;
  4109.       break;
  4110.  
  4111.     case LT:
  4112.     case LTU:
  4113.       val = op0 < op1;
  4114.       break;
  4115.  
  4116.     case GE:
  4117.     case GEU:
  4118.       val = op0 >= op1;
  4119.       break;
  4120.  
  4121.     case LE:
  4122.     case LEU:
  4123.       val = op0 <= op1;
  4124.     }
  4125.  
  4126.   return val ? const1_rtx : const0_rtx;
  4127. }
  4128.  
  4129. /* Generate code for a comparison expression EXP
  4130.    (including code to compute the values to be compared)
  4131.    and set (CC0) according to the result.
  4132.    SIGNED_FORWARD should be the rtx operation for this comparison for
  4133.    signed data; UNSIGNED_FORWARD, likewise for use if data is unsigned.
  4134.    SIGNED_REVERSE and UNSIGNED_REVERSE are used if it is desirable
  4135.    to interchange the operands for the compare instruction.
  4136.  
  4137.    We force a stack adjustment unless there are currently
  4138.    things pushed on the stack that aren't yet used.  */
  4139.  
  4140. static rtx
  4141. compare (exp, signed_forward, unsigned_forward,
  4142.      signed_reverse, unsigned_reverse)
  4143.      register tree exp;
  4144.      enum rtx_code signed_forward, unsigned_forward;
  4145.      enum rtx_code signed_reverse, unsigned_reverse;
  4146. {
  4147.  
  4148.   register rtx op0 = expand_expr (TREE_OPERAND (exp, 0), 0, VOIDmode, 0);
  4149.   register rtx op1 = expand_expr (TREE_OPERAND (exp, 1), 0, VOIDmode, 0);
  4150.   register enum machine_mode mode = GET_MODE (op0);
  4151.   int unsignedp;
  4152.  
  4153.   /* If one operand is 0, make it the second one.  */
  4154.  
  4155.   if (op0 == const0_rtx || op0 == fconst0_rtx || op0 == dconst0_rtx)
  4156.     {
  4157.       rtx tem = op0;
  4158.       op0 = op1;
  4159.       op1 = tem;
  4160.       signed_forward = signed_reverse;
  4161.       unsigned_forward = unsigned_reverse;
  4162.     }
  4163.  
  4164.   if (flag_force_mem)
  4165.     {
  4166.       op0 = force_not_mem (op0);
  4167.       op1 = force_not_mem (op1);
  4168.     }
  4169.  
  4170.   do_pending_stack_adjust ();
  4171.  
  4172.   unsignedp = (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0)))
  4173.            || TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 1))));
  4174.  
  4175.   if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
  4176.     return compare_constants (signed_forward, unsignedp,
  4177.                   INTVAL (op0), INTVAL (op1),
  4178.                   GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)))));
  4179.  
  4180.   emit_cmp_insn (op0, op1,
  4181.          (mode == BLKmode) ? expr_size (TREE_OPERAND (exp, 0)) : 0,
  4182.          unsignedp);
  4183.  
  4184.   return gen_rtx ((unsignedp ? unsigned_forward : signed_forward),
  4185.           VOIDmode, cc0_rtx, const0_rtx);
  4186. }
  4187.  
  4188. /* Like compare but expects the values to compare as two rtx's.
  4189.    The decision as to signed or unsigned comparison must be made by the caller.
  4190.    BLKmode is not allowed.  */
  4191.  
  4192. static rtx
  4193. compare1 (op0, op1, forward_op, reverse_op, unsignedp, mode)
  4194.      register rtx op0, op1;
  4195.      enum rtx_code forward_op, reverse_op;
  4196.      int unsignedp;
  4197.      enum machine_mode mode;
  4198. {
  4199.   /* If one operand is 0, make it the second one.  */
  4200.  
  4201.   if (op0 == const0_rtx || op0 == fconst0_rtx || op0 == dconst0_rtx)
  4202.     {
  4203.       rtx tem = op0;
  4204.       op0 = op1;
  4205.       op1 = tem;
  4206.       forward_op = reverse_op;
  4207.     }
  4208.  
  4209.   if (flag_force_mem)
  4210.     {
  4211.       op0 = force_not_mem (op0);
  4212.       op1 = force_not_mem (op1);
  4213.     }
  4214.  
  4215.   do_pending_stack_adjust ();
  4216.  
  4217.   if (GET_CODE (op0) == CONST_INT && GET_CODE (op1) == CONST_INT)
  4218.     return compare_constants (forward_op, unsignedp,
  4219.                   INTVAL (op0), INTVAL (op1),
  4220.                   GET_MODE_BITSIZE (mode));
  4221.  
  4222.   emit_cmp_insn (op0, op1, 0, unsignedp);
  4223.  
  4224.   return gen_rtx (forward_op, VOIDmode, cc0_rtx, const0_rtx);
  4225. }
  4226.  
  4227. /* Generate code to calculate EXP using a store-flag instruction
  4228.    and return an rtx for the result.
  4229.    If TARGET is nonzero, store the result there if convenient.
  4230.  
  4231.    Return zero if there is no suitable set-flag instruction
  4232.    available on this machine.  */
  4233.  
  4234. static rtx
  4235. do_store_flag (exp, target, mode)
  4236.      tree exp;
  4237.      rtx target;
  4238.      enum machine_mode mode;
  4239. {
  4240.   register enum tree_code code = TREE_CODE (exp);
  4241.   register rtx comparison = 0;
  4242.   enum machine_mode compare_mode;
  4243.  
  4244.   switch (code)
  4245.     {
  4246. #ifdef HAVE_seq
  4247.     case EQ_EXPR:
  4248.       if (HAVE_seq)
  4249.     {
  4250.       comparison = compare (exp, EQ, EQ, EQ, EQ);
  4251.       compare_mode = insn_operand_mode[(int) CODE_FOR_seq][0];
  4252.     }
  4253.       break;
  4254. #endif
  4255.  
  4256. #ifdef HAVE_sne
  4257.     case NE_EXPR:
  4258.       if (HAVE_sne)
  4259.     {
  4260.       comparison = compare (exp, NE, NE, NE, NE);
  4261.       compare_mode = insn_operand_mode[(int) CODE_FOR_sne][0];
  4262.     }
  4263.       break;
  4264. #endif
  4265.  
  4266. #if defined (HAVE_slt) && defined (HAVE_sltu) && defined (HAVE_sgt) && defined (HAVE_sgtu)
  4267.     case LT_EXPR:
  4268.       if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu)
  4269.     {
  4270.       comparison = compare (exp, LT, LTU, GT, GTU);
  4271.       compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0];
  4272.     }
  4273.       break;
  4274.  
  4275.     case GT_EXPR:
  4276.       if (HAVE_slt && HAVE_sltu && HAVE_sgt && HAVE_sgtu)
  4277.     {
  4278.       comparison = compare (exp, GT, GTU, LT, LTU);
  4279.       compare_mode = insn_operand_mode[(int) CODE_FOR_slt][0];
  4280.     }
  4281.       break;
  4282. #endif
  4283.  
  4284. #if defined (HAVE_sle) && defined (HAVE_sleu) && defined (HAVE_sge) && defined (HAVE_sgeu)
  4285.     case LE_EXPR:
  4286.       if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu)
  4287.     {
  4288.       comparison = compare (exp, LE, LEU, GE, GEU);
  4289.       compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0];
  4290.     }
  4291.       break;
  4292.  
  4293.     case GE_EXPR:
  4294.       if (HAVE_sle && HAVE_sleu && HAVE_sge && HAVE_sgeu)
  4295.     {
  4296.       comparison = compare (exp, GE, GEU, LE, LEU);
  4297.       compare_mode = insn_operand_mode[(int) CODE_FOR_sle][0];
  4298.     }
  4299.       break;
  4300. #endif
  4301.     }
  4302.   if (comparison == 0)
  4303.     return 0;
  4304.  
  4305.   if (target == 0 || GET_MODE (target) != mode
  4306.       || (mode != compare_mode && GET_CODE (target) != REG))
  4307.     target = gen_reg_rtx (mode);
  4308.  
  4309.   /* Store the comparison in its proper mode.  */
  4310.   if (GET_MODE (target) != compare_mode)
  4311.     emit_insn (gen_rtx (SET, VOIDmode,
  4312.             gen_rtx (SUBREG, compare_mode, target, 0),
  4313.             comparison));
  4314.   else
  4315.     emit_insn (gen_rtx (SET, VOIDmode, target, comparison));
  4316.  
  4317. #if STORE_FLAG_VALUE != 1
  4318.   expand_bit_and (mode, target, const1_rtx, target);
  4319. #endif
  4320.   return target;
  4321. }
  4322.  
  4323. /* Generate a tablejump instruction (used for switch statements).  */
  4324.  
  4325. #ifdef HAVE_tablejump
  4326.  
  4327. /* INDEX is the value being switched on, with the lowest value
  4328.    in the table already subtracted.
  4329.    RANGE is the length of the jump table.
  4330.    TABLE_LABEL is a CODE_LABEL rtx for the table itself.
  4331.  
  4332.    DEFAULT_LABEL is a CODE_LABEL rtx to jump to if the
  4333.    index value is out of range.  */
  4334.  
  4335. void
  4336. do_tablejump (index, range, table_label, default_label)
  4337.      rtx index, range, table_label, default_label;
  4338. {
  4339.   register rtx temp;
  4340.  
  4341.   emit_cmp_insn (range, index, 0);
  4342.   emit_jump_insn (gen_bltu (default_label));
  4343.   /* If flag_force_addr were to affect this address
  4344.      it could interfere with the tricky assumptions made
  4345.      about addresses that contain label-refs,
  4346.      which may be valid only very near the tablejump itself.  */
  4347.   index = memory_address_noforce
  4348.     (CASE_VECTOR_MODE,
  4349.      gen_rtx (PLUS, Pmode,
  4350.           gen_rtx (MULT, Pmode, index,
  4351.                gen_rtx (CONST_INT, VOIDmode,
  4352.                 GET_MODE_SIZE (CASE_VECTOR_MODE))),
  4353.           gen_rtx (LABEL_REF, VOIDmode, table_label)));
  4354.   temp = gen_reg_rtx (CASE_VECTOR_MODE);
  4355.   convert_move (temp, gen_rtx (MEM, CASE_VECTOR_MODE, index), 0);
  4356.  
  4357.   emit_jump_insn (gen_tablejump (temp, table_label));
  4358. }
  4359.  
  4360. #endif /* HAVE_tablejump */
  4361.